if (value.size() == 1) if (value.representation() == PrimitiveValue.Representation.LONG) buffer.putByte(0, (byte)value.longValue()); buffer.putByte(0, value.byteArrayValue()[0]); buffer.putBytes(0, value.byteArrayValue(), 0, value.byteArrayValue().length); return value.byteArrayValue().length; buffer.putByte(0, (byte)value.longValue()); return 1; buffer.putShort(0, (short)value.longValue(), ByteOrder.LITTLE_ENDIAN); return 2; buffer.putInt(0, (int)value.longValue(), ByteOrder.LITTLE_ENDIAN); return 4; buffer.putLong(0, value.longValue(), ByteOrder.LITTLE_ENDIAN); return 8; buffer.putByte(0, (byte)value.longValue()); return 1; buffer.putShort(0, (short)value.longValue(), ByteOrder.LITTLE_ENDIAN); return 2;
primitiveValue = PrimitiveValue.parse(nodeValue, primitiveType, characterEncoding); primitiveValue = PrimitiveValue.parse(nodeValue, length, characterEncoding); primitiveValue = PrimitiveValue.parse(nodeValue, valueLength, characterEncoding); primitiveValue = PrimitiveValue.parse(nodeValue, length, characterEncoding);
cppTypeName, propertyName, generateLiteral(token.encoding().primitiveType(), token.encoding().constValue().toString())); final byte[] constantValue = token.encoding().constValue().byteArrayValue(token.encoding().primitiveType()); final StringBuilder values = new StringBuilder(); for (final byte b : constantValue)
/** * Construct a Choice given the XML node and the encodingType * * @param node that contains the validValue * @param encodingType for the enum */ public Choice(final Node node, final PrimitiveType encodingType) { name = getAttributeValue(node, "name"); description = getAttributeValueOrNull(node, "description"); value = PrimitiveValue.parse(node.getFirstChild().getNodeValue(), encodingType); sinceVersion = Integer.parseInt(getAttributeValue(node, "sinceVersion", "0")); deprecated = Integer.parseInt(getAttributeValue(node, "deprecated", "0")); // choice values are bit positions (0, 1, 2, 3, 4, etc.) from LSB to MSB if (value.longValue() >= (encodingType.size() * 8)) { throw new IllegalArgumentException("Choice value out of bounds: " + value.longValue()); } checkForValidName(node, name); }
if (null != constOrNotPresentValue) if (constOrNotPresentValue.size() == 1) final byte[] bytes = { (byte)constOrNotPresentValue.longValue() }; return new String(bytes, constOrNotPresentValue.characterEncoding()); return constOrNotPresentValue.toString();
/** * Return double value for this PrimitiveValue. * * @return value expressed as a double * @throws IllegalStateException if not a double value representation */ public double doubleValue() { if (representation != Representation.DOUBLE) { throw new IllegalStateException( "Not a double representation: representation=" + representation + " value=" + toString()); } return doubleValue; }
PrimitiveType( final String name, final int size, final double minValue, final double maxValue, final double nullValue) { this.name = name; this.size = size; this.minValue = new PrimitiveValue(minValue, size); this.maxValue = new PrimitiveValue(maxValue, size); this.nullValue = new PrimitiveValue(nullValue, size); }
arrayLength = token.encoding().constValue().size(); // can be 1 sb.append("\t").append(propertyName) .append(String.format(String.format("%%%ds", longest - propertyName.length() + 1), " "))
/** * Return byte array value for this PrimitiveValue. * * @return value expressed as a byte array * @throws IllegalStateException if not a byte array value representation */ public byte[] byteArrayValue() { if (representation != Representation.BYTE_ARRAY) { throw new IllegalStateException( "Not a byte[] representation: representation=" + representation + " value=" + toString()); } return byteArrayValue; }
private static void validateGroupMaxValue( final Node node, final PrimitiveType primitiveType, final PrimitiveValue value) { if (null != value) { final long longValue = value.longValue(); final long allowedValue = primitiveType.maxValue().longValue(); if (longValue > allowedValue) { XmlSchemaParser.handleError(node, String.format( "maxValue greater than allowed for type: maxValue=%d allowed=%d", longValue, allowedValue)); } final long maxInt = INT32.maxValue().longValue(); if (primitiveType == UINT32 && longValue > maxInt) { XmlSchemaParser.handleError(node, String.format( "maxValue greater than allowed for type: maxValue=%d allowed=%d", longValue, maxInt)); } } else if (primitiveType == UINT32) { final long maxInt = INT32.maxValue().longValue(); XmlSchemaParser.handleError(node, String.format( "maxValue must be set for varData UINT32 type: max value allowed=%d", maxInt)); } }
PrimitiveType(final String name, final int size, final long minValue, final long maxValue, final long nullValue) { this.name = name; this.size = size; this.minValue = new PrimitiveValue(minValue, size); this.maxValue = new PrimitiveValue(maxValue, size); this.nullValue = new PrimitiveValue(nullValue, size); }
encodingToken.encoding().primitiveType() == CHAR) arrayspec = "[" + encodingToken.encoding().constValue().size() + "]";
if (value.size() == 1) CodecUtil.charPut(buffer, 0, (byte)value.longValue()); return 1; CodecUtil.charsPut(buffer, 0, value.byteArrayValue(), 0, value.byteArrayValue().length); return value.byteArrayValue().length; CodecUtil.int8Put(buffer, 0, (byte)value.longValue()); return 1; CodecUtil.int16Put(buffer, 0, (short)value.longValue(), ByteOrder.LITTLE_ENDIAN); return 2; CodecUtil.int32Put(buffer, 0, (int)value.longValue(), ByteOrder.LITTLE_ENDIAN); return 4; CodecUtil.int64Put(buffer, 0, value.longValue(), ByteOrder.LITTLE_ENDIAN); return 8; CodecUtil.uint8Put(buffer, 0, (short)value.longValue()); return 1; CodecUtil.uint16Put(buffer, 0, (int)value.longValue(), ByteOrder.LITTLE_ENDIAN); return 2; CodecUtil.uint32Put(buffer, 0, value.longValue(), ByteOrder.LITTLE_ENDIAN); return 4;
javaTypeName(encoding.primitiveType()), formattedPropertyName, generateLiteral(encoding.primitiveType(), encoding.constValue().toString())); final byte[] constBytes = encoding.constValue().byteArrayValue(encoding.primitiveType()); final CharSequence values = generateByteLiteralList( encoding.constValue().byteArrayValue(encoding.primitiveType()));