Example usage for java.lang Byte Byte

List of usage examples for java.lang Byte Byte

Introduction

In this page you can find the example usage for java.lang Byte Byte.

Prototype

@Deprecated(since = "9")
public Byte(String s) throws NumberFormatException 

Source Link

Document

Constructs a newly allocated Byte object that represents the byte value indicated by the String parameter.

Usage

From source file:org.n52.wps.server.request.InputHandler.java

private boolean checkRange(IData parameterObj, RangeType allowedRange) {

    List<?> l = allowedRange.getRangeClosure();

    /*//from w  w  w .j a  v a  2s. co  m
     * no closure info or RangeClosure is "closed", so include boundaries
     */
    if (l == null || l.isEmpty() || l.get(0).equals("closed")) {

        if ((parameterObj instanceof LiteralIntBinding)) {
            int min = new Integer(allowedRange.getMinimumValue().getStringValue());
            int max = new Integer(allowedRange.getMaximumValue().getStringValue());
            if ((Integer) (parameterObj.getPayload()) >= min && (Integer) parameterObj.getPayload() <= max) {
                return true;
            }
        }
        if ((parameterObj instanceof LiteralDoubleBinding)) {
            Double min = new Double(allowedRange.getMinimumValue().getStringValue());
            Double max = new Double(allowedRange.getMaximumValue().getStringValue());
            if ((Double) (parameterObj.getPayload()) >= min && (Double) parameterObj.getPayload() <= max) {
                return true;
            }
        }
        if ((parameterObj instanceof LiteralShortBinding)) {
            Short min = new Short(allowedRange.getMinimumValue().getStringValue());
            Short max = new Short(allowedRange.getMaximumValue().getStringValue());
            if ((Short) (parameterObj.getPayload()) >= min && (Short) parameterObj.getPayload() <= max) {
                return true;
            }
        }
        if ((parameterObj instanceof LiteralFloatBinding)) {
            Float min = new Float(allowedRange.getMinimumValue().getStringValue());
            Float max = new Float(allowedRange.getMaximumValue().getStringValue());
            if ((Float) (parameterObj.getPayload()) >= min && (Float) parameterObj.getPayload() <= max) {
                return true;
            }
        }
        if ((parameterObj instanceof LiteralLongBinding)) {
            Long min = new Long(allowedRange.getMinimumValue().getStringValue());
            Long max = new Long(allowedRange.getMaximumValue().getStringValue());
            if ((Long) (parameterObj.getPayload()) >= min && (Long) parameterObj.getPayload() <= max) {
                return true;
            }
        }
        if ((parameterObj instanceof LiteralByteBinding)) {
            Byte min = new Byte(allowedRange.getMinimumValue().getStringValue());
            Byte max = new Byte(allowedRange.getMaximumValue().getStringValue());
            if ((Byte) (parameterObj.getPayload()) >= min && (Byte) parameterObj.getPayload() <= max) {
                return true;
            }
        }
        return false;
    }
    /*
     * TODO:implement other closure cases
     */

    return false;
}

From source file:ar.com.fdvs.dj.core.layout.Dj2JrCrosstabBuilder.java

/**
 * Registers the Columngroup Buckets and creates the header cell for the columns
 */// ww  w. ja  v  a  2  s  .co m
private void registerColumns() {
    for (int i = 0; i < cols.length; i++) {
        DJCrosstabColumn crosstabColumn = cols[i];

        JRDesignCrosstabColumnGroup ctColGroup = new JRDesignCrosstabColumnGroup();
        ctColGroup.setName(crosstabColumn.getProperty().getProperty());
        ctColGroup.setHeight(crosstabColumn.getHeaderHeight());

        JRDesignCrosstabBucket bucket = new JRDesignCrosstabBucket();

        JRDesignExpression bucketExp = ExpressionUtils.createExpression(
                "$F{" + crosstabColumn.getProperty().getProperty() + "}",
                crosstabColumn.getProperty().getValueClassName());
        bucket.setExpression(bucketExp);

        ctColGroup.setBucket(bucket);

        JRDesignCellContents colHeaerContent = new JRDesignCellContents();
        JRDesignTextField colTitle = new JRDesignTextField();

        JRDesignExpression colTitleExp = new JRDesignExpression();
        colTitleExp.setValueClassName(crosstabColumn.getProperty().getValueClassName());
        colTitleExp.setText("$V{" + crosstabColumn.getProperty().getProperty() + "}");

        colTitle.setExpression(colTitleExp);
        colTitle.setWidth(crosstabColumn.getWidth());
        colTitle.setHeight(crosstabColumn.getHeaderHeight());

        //The height can be the sum of the heights of all the columns starting from the current one, up to the inner most one.
        int auxWidth = calculateRowHeaderMaxWidth(crosstabColumn);
        colTitle.setWidth(auxWidth);

        Style headerstyle = crosstabColumn.getHeaderStyle() == null ? this.djcross.getColumnHeaderStyle()
                : crosstabColumn.getHeaderStyle();

        if (headerstyle != null) {
            layoutManager.applyStyleToElement(headerstyle, colTitle);
            colHeaerContent.setBackcolor(headerstyle.getBackgroundColor());
        }

        colHeaerContent.addElement(colTitle);
        colHeaerContent.setMode(new Byte(Transparency.OPAQUE.getValue()));
        applyCellBorder(colHeaerContent);

        ctColGroup.setHeader(colHeaerContent);

        if (crosstabColumn.isShowTotals())
            createColumTotalHeader(ctColGroup, crosstabColumn);

        try {
            jrcross.addColumnGroup(ctColGroup);
        } catch (JRException e) {
            log.error(e.getMessage(), e);
        }
    }
}

From source file:gov.noaa.pfel.erddap.dataset.EDDTableFromHttpGet.java

/** 
     * This is used to add insert or delete commands into a data file of this dataset. 
     * This is EDDTableFromHttpGet overwriting the default implementation.
     *//w w w.j a  v a2 s. c  o m
     * <p>The key should be author_secret. So keys are specific to specific people/actors.
     * The author will be kept and added to the 'author' column in the dataset.
     *
     * <p>INSERT works like SQL's INSERT and UPDATE.
     * If the info matches existing values of sortColumnSourceNames,
     * the previous data is updated/overwritten. Otherwise, it is inserted.
     *
     * <p>DELETE works like SQL's DELETE
     *
     * @param tDirStructureColumnNames the column names for the parts of the 
     *   dir and file names. All of these names must be in requiredColumnNames.
     * @param keys the valid values of author= (to authenticate the author)
     * @param columnNames the names of all of the dataset's source variables.
     *   This does not include timestamp, author, or command.
     *   The time variable must be named time.
     * @param columnUnits any of them may be null or "".
     *   All timestamp columns (in the general sense) should have UDUNITS 
     *   String time units (e.g., "yyyy-MM-dd'T'HH:mm:ss") 
     *   or numeric time units (e.g., "days since 1985-01-01").
     *   For INSERT and DELETE calls, the time values must be in that format
     *   (you can't revert to ISO 8601 format as with data requests in the rest of ERDDAP).
     * @param columnTypes the Java names for the types (e.g., double).
     *   The missing values are the default missing values for PrimitiveArrays.
     *   All timestamp columns MUST be doubles.
     *   'long' is not supported because .nc3 files don't support longs.
     * @param columnStringLengths -1 if not a string column.
     * @param requiredColumnNames the names which identify a unique row.
     *   RequiredColumnNames MUST all be in columnNames.
     *   Insert requests MUST have all of the requiredColumnNames and usually have all 
     *     columnNames + author. Missing columns will get (standard PrimitiveArray) 
     *     missing values.
     *   Delete requests MUST have all of the requiredColumnNames and, in addition,
     *     usually have just author. Other columns are irrelevant.
     *   This should be as minimal as possible, and always includes time:  
     *   For TimeSeries: stationID, time.
     *   For Trajectory: trajectoryID, time.
     *   For Profile: stationID, time, depth.
     *   For TimeSeriesProfile: stationID, time, depth.
     *   For TrajectoryProfile: trajectoryID, time, depth.
     * @param command INSERT_COMMAND or DELETE_COMMAND
     * @param userDapQuery the param string, still percent-encoded
     * @param dirTable  a copy of the dirTable  (changes may be made to it) or null.
     * @param fileTable a copy of the fileTable (changes may be made to it) or null.
     * @return the response string 
     * @throws Throwable if any kind of trouble
     */
    public static String insertOrDelete(String startDir, StringArray tDirStructureColumnNames,
            IntArray tDirStructureNs, IntArray tDirStructureCalendars, HashSet<String> keys, String columnNames[],
            String columnUnits[], String columnTypes[], int columnStringLengths[], String requiredColumnNames[],
            byte command, String userDapQuery, Table dirTable, Table fileTable) throws Throwable {

        double timestamp = System.currentTimeMillis() / 1000.0;
        if (dirTable == null || fileTable == null) { //ensure both or neither
            dirTable = null;
            fileTable = null;
        }

        //store values parallelling columnNames
        int nColumns = columnNames.length;
        PrimitiveArray columnValues[] = new PrimitiveArray[nColumns];
        Class columnClasses[] = new Class[nColumns];
        DataType columnDataTypes[] = new DataType[nColumns];
        boolean columnIsString[] = new boolean[nColumns];
        int timeColumn = -1;
        DateTimeFormatter timeFormatter = null; //used if time variable is string
        double timeBaseAndFactor[] = null; //used if time variable is numeric
        for (int col = 0; col < nColumns; col++) {
            if (!String2.isSomething(columnUnits[col]))
                columnUnits[col] = "";

            if (columnNames[col].equals(EDV.TIME_NAME)) {
                timeColumn = col;
                if (columnIsString[col]) {
                    if (columnUnits[col].toLowerCase().indexOf("yyyy") < 0) //was "yy"
                        throw new SimpleException(
                                EDStatic.queryError + "Invalid units for the string time variable. "
                                        + "Units MUST specify the format of the time values.");
                    timeFormatter = DateTimeFormat.forPattern(columnUnits[col]).withZone(ZoneId.of("UTC"));
                } else { //numeric time values
                    timeBaseAndFactor = Calendar2.getTimeBaseAndFactor(columnUnits[col]); //throws RuntimeException if trouble
                }
            }

            if (columnTypes[col].equals("String")) {
                columnClasses[col] = String.class;
                columnDataTypes[col] = DataType.STRING;
                columnIsString[col] = true;
                if (columnStringLengths[col] < 1 || columnStringLengths[col] > 64000)
                    throw new SimpleException(EDStatic.queryError + "Invalid string length="
                            + columnStringLengths[col] + " for column=" + columnNames[col] + ".");
            } else {
                columnClasses[col] = PrimitiveArray.elementStringToClass(columnTypes[col]);
                columnDataTypes[col] = NcHelper.getDataType(columnClasses[col]);
            }
        }

        //parse the userDapQuery's parts. Ensure it is valid. 
        String parts[] = String2.split(userDapQuery, '&');
        int nParts = parts.length;
        String author = null; //the part before '_'
        int arraySize = -1; //until an array is found
        BitSet requiredColumnsFound = new BitSet();
        for (int p = 0; p < nParts; p++) {
            parts[p] = SSR.percentDecode(parts[p]);
            int eqPo = parts[p].indexOf('=');
            if (eqPo <= 0 || //no '=' or no name
                    "<>~!".indexOf(parts[p].charAt(eqPo - 1)) >= 0) // <= >= != ~=
                throw new SimpleException(
                        EDStatic.queryError + "The \"" + parts[p] + "\" parameter isn't in the form name=value.");
            String tName = parts[p].substring(0, eqPo);
            String tValue = parts[p].substring(eqPo + 1);
            if (tValue.startsWith("~")) // =~
                throw new SimpleException(
                        EDStatic.queryError + "The \"" + parts[p] + "\" parameter isn't in the form name=value.");

            //catch and verify author=
            if (tName.equals(AUTHOR)) {
                if (author != null)
                    throw new SimpleException(EDStatic.queryError + "There are two parameters with name=author.");
                if (!keys.contains(tValue))
                    throw new SimpleException(EDStatic.queryError + "Invalid author_key.");
                if (p != nParts - 1)
                    throw new SimpleException(EDStatic.queryError + "name=author must be the last parameter.");
                int po = Math.max(0, tValue.indexOf('_'));
                author = tValue.substring(0, po); //may be ""

            } else {
                //is it a requiredColumn?
                int whichRC = String2.indexOf(requiredColumnNames, tName);
                if (whichRC >= 0)
                    requiredColumnsFound.set(whichRC);

                //whichColumn? 
                int whichCol = String2.indexOf(columnNames, tName);
                if (whichCol < 0)
                    throw new SimpleException(EDStatic.queryError + "Unknown columnName=" + tName);
                if (columnValues[whichCol] != null)
                    throw new SimpleException(
                            EDStatic.queryError + "There are two parameters with columnName=" + tName + ".");

                //get the values
                if (tValue.startsWith("[") && tValue.endsWith("]")) {
                    //deal with array of values: name=[valuesCSV]
                    columnValues[whichCol] = PrimitiveArray.csvFactory(columnClasses[whichCol], tValue);
                    if (arraySize < 0)
                        arraySize = columnValues[whichCol].size();
                    else if (arraySize != columnValues[whichCol].size())
                        throw new SimpleException(
                                EDStatic.queryError + "Different parameters with arrays have different sizes: "
                                        + arraySize + "!=" + columnValues[whichCol].size() + ".");

                } else {
                    //deal with single value: name=value
                    columnValues[whichCol] = PrimitiveArray.csvFactory(columnClasses[whichCol], tValue);

                    if (columnClasses[whichCol] == String.class && (tValue.length() < 2 || tValue.charAt(0) != '"'
                            || tValue.charAt(tValue.length() - 1) != '"'))
                        throw new SimpleException(EDStatic.queryError + "The String value for columnName=" + tName
                                + " must start and end with \"'s.");
                    if (columnValues[whichCol].size() != 1)
                        throw new SimpleException(
                                EDStatic.queryError + "One value (not " + columnValues[whichCol].size()
                                        + ") expected for columnName=" + tName + ". (missing [ ] ?)");
                }
            }
        }

        //ensure required parameters were specified 
        if (author == null)
            throw new SimpleException(EDStatic.queryError + "author= was not specified.");
        int notFound = requiredColumnsFound.nextClearBit(0);
        if (notFound < requiredColumnNames.length)
            throw new SimpleException(EDStatic.queryError + "requiredColumnName=" + requiredColumnNames[notFound]
                    + " wasn't specified.");

        //make all columnValues the same size
        //(timestamp, author, command are separate and have just 1 value)
        int maxSize = Math.max(1, arraySize);
        for (int col = 0; col < nColumns; col++) {
            PrimitiveArray pa = columnValues[col];
            if (pa == null) {
                //this var wasn't in the command, so use mv's
                columnValues[col] = PrimitiveArray.factory(columnClasses[col], maxSize, "");
            } else if (pa.size() == 1 && maxSize > 1) {
                columnValues[col] = PrimitiveArray.factory(columnClasses[col], maxSize, pa.getString(0));
            }
        }

        //figure out the fullFileName for each row
        StringArray fullFileNames = new StringArray(maxSize, false);
        for (int row = 0; row < maxSize; row++) {
            //figure out the epochSeconds time value
            double tTime = timeColumn < 0 ? Double.NaN : //no time column
                    timeBaseAndFactor == null
                            ? Calendar2.toEpochSeconds(columnValues[timeColumn].getString(row), timeFormatter)
                            : Calendar2.unitsSinceToEpochSeconds( //numeric time
                                    timeBaseAndFactor[0], timeBaseAndFactor[1],
                                    columnValues[timeColumn].getDouble(row));

            fullFileNames.add(whichFile(startDir, tDirStructureColumnNames, tDirStructureNs, tDirStructureCalendars,
                    columnNames, columnValues, row, tTime));
        }

        //EVERYTHING SHOULD BE VALIDATED BY NOW. NO ERRORS AFTER HERE!
        //append each input row to the appropriate file
        Array oneTimestampArray = Array.factory(new double[] { timestamp });
        //I reported to netcdf-java mailing list: this generated null pointer exception in 4.6.6:
        // String tsar[] = new String[]{author};
        // Array oneAuthorArray    = Array.factory(tsar); //new String[]{author});
        //This works:
        ArrayString.D1 oneAuthorArray = new ArrayString.D1(1);
        oneAuthorArray.set(0, author);

        Array oneCommandArray = Array.factory(new byte[] { command });
        int row = 0;
        while (row < maxSize) {
            //figure out which file
            String fullFileName = fullFileNames.get(row);

            //open the file
            NetcdfFileWriter file = null;
            boolean fileIsNew = false;
            int[] origin = new int[1];
            try {

                Group rootGroup = null;
                Dimension rowDim = null;
                Variable vars[] = new Variable[nColumns];
                Variable timestampVar = null;
                Variable authorVar = null;
                Variable commandVar = null;
                if (File2.isFile(fullFileName)) {
                    file = NetcdfFileWriter.openExisting(fullFileName);
                    rootGroup = file.addGroup(null, "");
                    rowDim = rootGroup.findDimension("row");

                    //find Variables for columnNames.   May be null, but shouldn't be.
                    StringArray columnsNotFound = new StringArray();
                    for (int col = 0; col < nColumns; col++) {
                        vars[col] = rootGroup.findVariable(columnNames[col]);
                        if (vars[col] == null)
                            columnsNotFound.add(columnNames[col]);
                    }
                    timestampVar = rootGroup.findVariable(TIMESTAMP);
                    authorVar = rootGroup.findVariable(AUTHOR);
                    commandVar = rootGroup.findVariable(COMMAND);
                    if (timestampVar == null)
                        columnsNotFound.add(TIMESTAMP);
                    if (authorVar == null)
                        columnsNotFound.add(AUTHOR);
                    if (commandVar == null)
                        columnsNotFound.add(COMMAND);
                    if (columnsNotFound.size() > 0)
                        throw new SimpleException(MustBe.InternalError + ": column(s)=" + columnsNotFound
                                + " not found in " + fullFileName);

                } else {
                    //if file doesn't exist, create it
                    fileIsNew = true; //first
                    file = NetcdfFileWriter.createNew(NetcdfFileWriter.Version.netcdf3, fullFileName);
                    rootGroup = file.addGroup(null, "");
                    rowDim = file.addUnlimitedDimension("row");
                    ArrayList rowDimAL = new ArrayList();
                    rowDimAL.add(rowDim);

                    //define Variables
                    for (int col = 0; col < nColumns; col++) {
                        String cName = columnNames[col];
                        String cType = columnTypes[col];
                        if (columnIsString[col]) {
                            vars[col] = file.addStringVariable(rootGroup, cName, rowDimAL,
                                    columnStringLengths[col]);
                        } else {
                            vars[col] = file.addVariable(rootGroup, cName, columnDataTypes[col], rowDimAL);
                        }
                    }
                    timestampVar = file.addVariable(rootGroup, TIMESTAMP, DataType.DOUBLE, rowDimAL);
                    authorVar = file.addStringVariable(rootGroup, AUTHOR, rowDimAL, AUTHOR_STRLEN);
                    commandVar = file.addVariable(rootGroup, COMMAND, DataType.BYTE, rowDimAL);

                    // create the file
                    file.create();
                }

                //append the series of commands that go to this fullFileName
                int startRow = row++;
                while (row < maxSize && fullFileNames.get(row).equals(fullFileName))
                    row++;
                int stopRow = row; //1 past end

                //which row in the file table?
                int fileTableRow = -1;
                if (fileTable != null) {
                    //already in fileTable?
                    //fileTableRow = ...

                    //add to fileTable
                }

                //write the data to the file
                origin[0] = rowDim.getLength();
                for (int col = 0; col < nColumns; col++) {
                    PrimitiveArray subsetPA = columnValues[col];
                    if (startRow > 0 || stopRow != maxSize)
                        subsetPA = subsetPA.subset(startRow, 1, stopRow - 1); //inclusive
                    file.write(vars[col], origin, Array.factory(subsetPA.toObjectArray()));

                    //adjust min/max in fileTable
                    if (fileTable != null && command == INSERT_COMMAND) {
                        if (columnIsString[col]) {
                            //fileTableRow...   
                        } else {
                            double stats[] = subsetPA.calculateStats();
                            if (stats[PrimitiveArray.STATS_N] > 0) { //has some non MVs
                                //fileTableRow... Math.min(  , stats[PrimitiveArray.STATS_MIN]));
                                //fileTableRow....Math.max(  , stats[PrimitiveArray.STATS_MAX]));
                            }
                            if (stats[PrimitiveArray.STATS_N] < stopRow - startRow) {
                                //fileTableRow... hasMV
                            }
                        }
                    }
                }
                Array timestampArray = oneTimestampArray;
                Array authorArray = oneAuthorArray;
                Array commandArray = oneCommandArray;
                if (stopRow - startRow > 1) {
                    //double timestampAr[] = new double[stopRow - startRow]; 
                    //String authorAr[]    = new String[stopRow - startRow];
                    //byte   commandAr[]   = new byte  [stopRow - startRow];
                    //Arrays.fill(timestampAr, timestamp);
                    //Arrays.fill(authorAr,    author);
                    //Arrays.fill(commandAr,   command);
                    //timestampArray = Array.factory(timestampAr);
                    //authorArray    = Array.factory(authorAr);
                    //commandArray   = Array.factory(commandAr);

                    int thisShape[] = new int[] { stopRow - startRow };
                    timestampArray = Array.factoryConstant(double.class, thisShape, new Double(timestamp));
                    authorArray = Array.factoryConstant(String.class, thisShape, author);
                    commandArray = Array.factoryConstant(byte.class, thisShape, new Byte(command));
                }
                file.write(timestampVar, origin, timestampArray);
                file.writeStringData(authorVar, origin, authorArray);
                file.write(commandVar, origin, commandArray);

                //adjust min/max in fileTable
                if (fileTable != null && command == INSERT_COMMAND) {
                    //fileTableRow... Math.min(   , timestamp));
                    //fileTableRow....Math.max(   , timestamp));

                    //fileTableRow... Math.min(   , author));
                    //fileTableRow....Math.max(   , author));

                    //fileTableRow... Math.min(   , command));
                    //fileTableRow....Math.max(   , command));
                }

                //make it so!
                file.flush(); //force file update

                //close the file
                file.close();
                file = null;

            } catch (Throwable t) {
                if (file != null) {
                    try {
                        file.close();
                    } catch (Throwable t2) {
                    }
                }
                if (fileIsNew)
                    File2.delete(fullFileName);
                String2.log(
                        String2.ERROR + " while " + (fileIsNew ? "creating" : "adding to") + " " + fullFileName);
                throw t;
            }
        }

        //Don't ever change any of this (except adding somthing new to the end). 
        //Clients rely on it.
        return "SUCCESS: Data received. No errors. timestamp=" + Calendar2.epochSecondsToIsoStringT3(timestamp)
                + "Z=" + timestamp + " seconds since 1970-01-01T00:00:00Z.\n";
    }

From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link PositionTypeEnum}.
 *///from www. j  a v  a 2s.c  o m
public static Map getPositionTypeMap() {
    if (positionTypeMap == null) {
        Map map = new HashMap(8);
        map.put(POSITION_TYPE_FLOAT, new Byte(JRElement.POSITION_TYPE_FLOAT));
        map.put(POSITION_TYPE_FIX_RELATIVE_TO_TOP, new Byte(JRElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP));
        map.put(POSITION_TYPE_FIX_RELATIVE_TO_BOTTOM, new Byte(JRElement.POSITION_TYPE_FIX_RELATIVE_TO_BOTTOM));
        map.put(new Byte(JRElement.POSITION_TYPE_FLOAT), POSITION_TYPE_FLOAT);
        map.put(new Byte(JRElement.POSITION_TYPE_FIX_RELATIVE_TO_TOP), POSITION_TYPE_FIX_RELATIVE_TO_TOP);
        map.put(new Byte(JRElement.POSITION_TYPE_FIX_RELATIVE_TO_BOTTOM), POSITION_TYPE_FIX_RELATIVE_TO_BOTTOM);
        positionTypeMap = Collections.unmodifiableMap(map);
    }

    return positionTypeMap;
}

From source file:org.jboss.bqt.client.xml.XMLQueryVisitationStrategy.java

/**
 * Consume an XML message and update the specified Byte instance.
 * <br>/*from   w ww  .j av a  2s.  com*/
 * @param object the instance that is to be updated with the XML message data.
 * @param cellElement the XML element that contains the data
 * @return the updated instance.
 * @exception JDOMException if there is an error consuming the message.
 */
private Object consumeMsg(Byte object, Element cellElement) throws JDOMException {

    // -----------------------
    // Process the element ...
    // -----------------------
    Byte result;
    try {
        result = new Byte(cellElement.getTextTrim());
    } catch (NumberFormatException e) {
        throw new JDOMException("Unable to parse the value for " + cellElement.getName() + //$NON-NLS-1$
                " element: " + cellElement.getTextTrim(), e); //$NON-NLS-1$
    }
    return result;
}

From source file:net.sourceforge.msscodefactory.cfasterisk.v2_4.CFAsteriskXMsgClient.CFAsteriskXMsgClientSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {//from ww w .j a  va  2 s  . c om
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFAsteriskXMsgClientSchema.class,
                "getNullableByte", e);
    }
}

From source file:net.sf.jasperreports.engine.xml.JRXmlConstants.java

/**
 * @deprecated Replaced by {@link ModeEnum}.
 *///w  w w . j a va2 s.c o  m
public static Map getModeMap() {
    if (modeMap == null) {
        Map map = new HashMap(6);
        map.put(MODE_OPAQUE, new Byte(JRElement.MODE_OPAQUE));
        map.put(MODE_TRANSPARENT, new Byte(JRElement.MODE_TRANSPARENT));
        map.put(new Byte(JRElement.MODE_OPAQUE), MODE_OPAQUE);
        map.put(new Byte(JRElement.MODE_TRANSPARENT), MODE_TRANSPARENT);
        modeMap = Collections.unmodifiableMap(map);
    }

    return modeMap;
}

From source file:ar.com.fdvs.dj.core.layout.Dj2JrCrosstabBuilder.java

private void createRowTotalHeader(JRDesignCrosstabRowGroup ctRowGroup, DJCrosstabRow crosstabRow) {
    JRDesignCellContents totalHeaderContent = new JRDesignCellContents();
    ctRowGroup.setTotalHeader(totalHeaderContent);
    ctRowGroup.setTotalPosition(BucketDefinition.TOTAL_POSITION_END); //FIXME the total can be at the end of a group or at the beginin

    Style totalHeaderstyle = crosstabRow.getTotalHeaderStyle() == null ? this.djcross.getRowTotalheaderStyle()
            : crosstabRow.getTotalHeaderStyle();

    totalHeaderContent.setMode(new Byte(Transparency.OPAQUE.getValue()));

    JRDesignTextField element = new JRDesignTextField();

    JRDesignExpression exp;/*from ww w.j  av  a 2 s  .  co  m*/
    if (crosstabRow.getTotalLegend() != null) {
        exp = ExpressionUtils.createExpression("\"" + crosstabRow.getTotalLegend() + "\"", String.class);
    } else {
        exp = ExpressionUtils.createExpression("\"Total " + crosstabRow.getTitle() + "\"", String.class);
    }

    element.setExpression(exp);
    element.setHeight(crosstabRow.getHeight());

    if (totalHeaderstyle != null) {
        totalHeaderContent.setBackcolor(totalHeaderstyle.getBackgroundColor());
        layoutManager.applyStyleToElement(totalHeaderstyle, element);
    }

    //The width can be the sum of the with of all the rows starting from the current one, up to the inner most one.
    int auxWidth = 0;
    boolean found = false;
    for (Iterator iterator = djcross.getRows().iterator(); iterator.hasNext();) {
        DJCrosstabRow row = (DJCrosstabRow) iterator.next();
        if (!row.equals(crosstabRow) && found == false) {
            continue;
        } else {
            found = true;
        }

        auxWidth += row.getHeaderWidth();
    }
    element.setWidth(auxWidth);

    applyCellBorder(totalHeaderContent);

    totalHeaderContent.addElement(element);
}

From source file:com.willwinder.universalgcodesender.GrblControllerTest.java

/**
 * Test of rawResponseListener method, of class GrblController.
 *///from   w w w .jav  a 2s  .  c om
@Ignore("This has problems on the CI server.")
public void testPolling() {
    System.out.println("testPolling (via rawResponseListener)");
    GrblController instance = new GrblController(mgc);

    // Test 1. Check that polling works. (Grbl 0.8c)
    instance.rawResponseHandler("Grbl 0.8c");
    try {

        // Enough time for a few polling callsthe next poll to be sent.
        Thread.sleep(600);
    } catch (InterruptedException ex) {
        fail("Unexpected exception while testing rawResponseListener: " + ex.getMessage());
    }
    assertTrue(1 <= mgc.numSendByteImmediatelyCalls);
    //assertEquals(1, mgc.numSendByteImmediatelyCalls);
    assertEquals(new Byte(GrblUtils.GRBL_STATUS_COMMAND), mgc.sentBytes.get(mgc.sentBytes.size() - 1));

    // Test 2. Check that another poll is sent shortly after receiving a
    //         status message.
    instance.rawResponseHandler("<blah blah blah>");
    try {
        // Enough time for a few polling callsthe next poll to be sent.
        Thread.sleep(1000);
    } catch (InterruptedException ex) {
        fail("Unexpected exception while testing rawResponseListener: " + ex.getMessage());
    }
    assertEquals(2, mgc.numSendByteImmediatelyCalls);
    assertEquals(new Byte(GrblUtils.GRBL_STATUS_COMMAND), mgc.sentBytes.get(mgc.sentBytes.size() - 1));

    // Test 3. Check that after a long enough delay, additional polls are
    //         sent even without responses.
    try {
        // Enough time for a few polling callsthe next poll to be sent.
        Thread.sleep(5000);
    } catch (InterruptedException ex) {
        fail("Unexpected exception while testing rawResponseListener: " + ex.getMessage());
    }
    assert (2 < mgc.numSendByteImmediatelyCalls);
    assertEquals(new Byte(GrblUtils.GRBL_STATUS_COMMAND), mgc.sentBytes.get(mgc.sentBytes.size() - 1));
}

From source file:net.sourceforge.msscodefactory.cfsecurity.v2_0.CFSecurityPgSql.CFSecurityPgSqlSchema.java

public static Byte getNullableByte(ResultSet reader, int colidx) {
    try {/* www  .  j  a  v  a  2 s.  c om*/
        byte val = reader.getByte(colidx);
        if (reader.wasNull()) {
            return (null);
        } else {
            return (new Byte(val));
        }
    } catch (SQLException e) {
        throw CFLib.getDefaultExceptionFactory().newDbException(CFSecurityPgSqlSchema.class, "getNullableByte",
                e);
    }
}