Codota Logo
PrimitiveValue.parse
Code IndexAdd Codota to your IDE (free)

How to use
parse
method
in
uk.co.real_logic.sbe.PrimitiveValue

Best Java code snippets using uk.co.real_logic.sbe.PrimitiveValue.parse (Showing top 20 results out of 315)

  • Common ways to obtain PrimitiveValue
private void myMethod () {
PrimitiveValue p =
  • Codota IconString value;PrimitiveType primitiveType;PrimitiveValue.parse(value, primitiveType)
  • Codota IconEncoding encoding;encoding.applicableNullValue()
  • Codota IconEncoding encoding;encoding.nullValue()
  • Smart code suggestions by Codota
}
origin: real-logic/simple-binary-encoding

primitiveValue = PrimitiveValue.parse(nodeValue, primitiveType, characterEncoding);
primitiveValue = PrimitiveValue.parse(nodeValue, length, characterEncoding);
primitiveValue = PrimitiveValue.parse(nodeValue, valueLength, characterEncoding);
primitiveValue = PrimitiveValue.parse(nodeValue, length, characterEncoding);
origin: real-logic/simple-binary-encoding

/**
 * Construct a ValidValue given the XML node and the encodingType.
 *
 * @param node         that contains the validValue
 * @param encodingType for the enum
 */
public ValidValue(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"));
  checkForValidName(node, name);
}
origin: real-logic/simple-binary-encoding

/**
 * 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);
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldReturnCorrectConstantStringWhenSpecified()
  throws Exception
{
  final String strConst = "string constant";
  final String testXmlString =
    "<types>" +
    "    <type name=\"testTypeConstString\" primitiveType=\"char\" presence=\"constant\" " +
    "length=\"" + strConst.length() + "\"" +
    ">" + strConst + "</type>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/type", testXmlString);
  assertThat((((EncodedDataType)map.get("testTypeConstString")).constVal()),
    is(parse(strConst, strConst.length(), "US-ASCII")));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldReturnCorrectMaxValueWhenSpecified()
  throws Exception
{
  final String maxVal = "10";
  final String testXmlString =
    "<types>" +
    "    <type name=\"testTypeInt8MaxValue\" primitiveType=\"int8\" maxValue=\"" + maxVal + "\"/>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/type", testXmlString);
  assertThat((((EncodedDataType)map.get("testTypeInt8MaxValue")).maxValue()),
    is(parse(maxVal, PrimitiveType.INT8)));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldReturnCorrectMinValueWhenSpecified()
  throws Exception
{
  final String minVal = "10";
  final String testXmlString =
    "<types>" +
    "    <type name=\"testTypeInt8MinValue\" primitiveType=\"int8\" minValue=\"" + minVal + "\"/>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/type", testXmlString);
  assertThat((((EncodedDataType)map.get("testTypeInt8MinValue")).minValue()),
    is(parse(minVal, PrimitiveType.INT8)));
}
origin: real-logic/simple-binary-encoding

        constValue = PrimitiveValue.parse(nodeValue, primitiveType);
minValue = minValStr != null ? PrimitiveValue.parse(minValStr, primitiveType) : null;
maxValue = maxValStr != null ? PrimitiveValue.parse(maxValStr, primitiveType) : null;
  nullValue = PrimitiveValue.parse(nullValStr, primitiveType);
origin: real-logic/simple-binary-encoding

@Test
public void shouldReturnCorrectPresenceConstantWhenSpecified()
  throws Exception
{
  final String testXmlString =
    "<types>" +
    "    <type name=\"testTypePresenceConst\" primitiveType=\"char\" presence=\"constant\">F</type>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/type", testXmlString);
  final String expectedString = "F";
  final PrimitiveValue expectedValue = parse(expectedString, PrimitiveType.CHAR);
  assertThat((((EncodedDataType)map.get("testTypePresenceConst")).constVal()), is(expectedValue));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldReturnCorrectNullValueWhenSpecified()
  throws Exception
{
  final String nullVal = "10";
  final String testXmlString =
    "<types>" +
    "    <type name=\"testTypeInt8NullValue\" primitiveType=\"int8\" presence=\"optional\" nullValue=\"" +
    nullVal + "\"/>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/type", testXmlString);
  assertThat((((EncodedDataType)map.get("testTypeInt8NullValue")).nullValue()),
    is(parse(nullVal, PrimitiveType.INT8)));
}
origin: real-logic/simple-binary-encoding

nullValue = PrimitiveValue.parse(nullValueStr, encodingType);
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleCharEnumEncodingType()
  throws Exception
{
  final String testXmlString =
    "<types>" +
    "<enum name=\"mixed\" encodingType=\"char\">" +
    "    <validValue name=\"Cee\">C</validValue>" +
    "    <validValue name=\"One\">1</validValue>" +
    "    <validValue name=\"Two\">2</validValue>" +
    "    <validValue name=\"Eee\">E</validValue>" +
    "</enum>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/enum", testXmlString);
  final EnumType e = (EnumType)map.get("mixed");
  assertThat(e.encodingType(), is(PrimitiveType.CHAR));
  assertThat(e.getValidValue("Cee").primitiveValue(), is(PrimitiveValue.parse("C", PrimitiveType.CHAR)));
  assertThat(e.getValidValue("One").primitiveValue(), is(PrimitiveValue.parse("1", PrimitiveType.CHAR)));
  assertThat(e.getValidValue("Two").primitiveValue(), is(PrimitiveValue.parse("2", PrimitiveType.CHAR)));
  assertThat(e.getValidValue("Eee").primitiveValue(), is(PrimitiveValue.parse("E", PrimitiveType.CHAR)));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleCompositeHasNullableType()
  throws Exception
{
  final String nullValStr = "9223372036854775807";
  final String testXmlString =
    "<types>" +
    "<composite name=\"PRICENULL\" description=\"Price NULL\" semanticType=\"Price\">" +
    "    <type name=\"mantissa\" description=\"mantissa\" presence=\"optional\" nullValue=\"" +
    nullValStr + "\" primitiveType=\"int64\"/>" +
    "    <type name=\"exponent\" description=\"exponent\" presence=\"constant\" primitiveType=\"int8\">" +
    "-7</type>" +
    "</composite>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/composite", testXmlString);
  final CompositeType c = (CompositeType)map.get("PRICENULL");
  final EncodedDataType mantissa = (EncodedDataType)c.getType("mantissa");
  assertThat(mantissa.nullValue(), is(PrimitiveValue.parse(nullValStr, PrimitiveType.INT64)));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleOptionalBooleanEnumType()
  throws Exception
{
  final String nullValueStr = "255";
  final String testXmlString =
    "<types>" +
    "<enum name=\"optionalBoolean\" encodingType=\"uint8\" presence=\"optional\"" +
    "      nullValue=\"" + nullValueStr + "\" semanticType=\"Boolean\">" +
    "    <validValue name=\"False\">0</validValue>" +
    "    <validValue name=\"True\">1</validValue>" +
    "</enum>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/enum", testXmlString);
  final EnumType e = (EnumType)map.get("optionalBoolean");
  assertThat(e.name(), is("optionalBoolean"));
  assertThat(e.encodingType(), is(PrimitiveType.UINT8));
  assertThat(e.validValues().size(), is(2));
  assertThat(e.getValidValue("True").primitiveValue(), is(PrimitiveValue.parse("1", PrimitiveType.UINT8)));
  assertThat(e.getValidValue("False").primitiveValue(), is(PrimitiveValue.parse("0", PrimitiveType.UINT8)));
  assertThat(e.nullValue(), is(PrimitiveValue.parse(nullValueStr, PrimitiveType.UINT8)));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleBinarySetType()
  throws Exception
{
  final String testXmlString =
    "<types>" +
    "<set name=\"biOp\" encodingType=\"uint8\">" +
    "    <choice name=\"Bit0\" description=\"Bit 0\">0</choice>" +
    "    <choice name=\"Bit1\" description=\"Bit 1\">1</choice>" +
    "</set>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/set", testXmlString);
  final SetType e = (SetType)map.get("biOp");
  assertThat(e.name(), is("biOp"));
  assertThat(e.encodingType(), is(PrimitiveType.UINT8));
  assertThat(e.choices().size(), is(2));
  assertThat(e.getChoice("Bit1").primitiveValue(), is(PrimitiveValue.parse("1", PrimitiveType.UINT8)));
  assertThat(e.getChoice("Bit0").primitiveValue(), is(PrimitiveValue.parse("0", PrimitiveType.UINT8)));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleBooleanEnumType()
  throws Exception
{
  final String testXmlString =
    "<types>" +
    "<enum name=\"Boolean\" encodingType=\"uint8\" semanticType=\"Boolean\">" +
    "    <validValue name=\"False\">0</validValue>" +
    "    <validValue name=\"True\">1</validValue>" +
    "</enum>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/enum", testXmlString);
  final EnumType e = (EnumType)map.get("Boolean");
  assertThat(e.name(), is("Boolean"));
  assertThat(e.encodingType(), is(PrimitiveType.UINT8));
  assertThat(e.validValues().size(), is(2));
  assertThat(e.getValidValue("True").primitiveValue(), is(PrimitiveValue.parse("1", PrimitiveType.UINT8)));
  assertThat(e.getValidValue("False").primitiveValue(), is(PrimitiveValue.parse("0", PrimitiveType.UINT8)));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleBinaryEnumType()
  throws Exception
{
  final String testXmlString =
    "<types>" +
    "<enum name=\"biOp\" encodingType=\"uint8\">" +
    "    <validValue name=\"off\" description=\"switch is off\">0</validValue>" +
    "    <validValue name=\"on\" description=\"switch is on\">1</validValue>" +
    "</enum>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/enum", testXmlString);
  final EnumType e = (EnumType)map.get("biOp");
  assertThat(e.name(), is("biOp"));
  assertThat(e.encodingType(), is(PrimitiveType.UINT8));
  assertThat(e.validValues().size(), is(2));
  assertThat(e.getValidValue("on").primitiveValue(), is(PrimitiveValue.parse("1", PrimitiveType.UINT8)));
  assertThat(e.getValidValue("off").primitiveValue(), is(PrimitiveValue.parse("0", PrimitiveType.UINT8)));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleDecimal64CompositeType()
  throws Exception
{
  final String testXmlString =
    "<types>" +
    "<composite name=\"decimal64\">" +
    "    <type name=\"mantissa\" primitiveType=\"int64\"/>" +
    "    <type name=\"exponent\" primitiveType=\"int8\" presence=\"constant\">-2</type>" +
    "</composite>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/composite", testXmlString);
  final CompositeType decimal64 = (CompositeType)map.get("decimal64");
  assertThat(decimal64.name(), is("decimal64"));
  final EncodedDataType mantissa = (EncodedDataType)decimal64.getType("mantissa");
  final EncodedDataType exponent = (EncodedDataType)decimal64.getType("exponent");
  assertThat(mantissa.primitiveType(), is(PrimitiveType.INT64));
  assertThat(exponent.primitiveType(), is(PrimitiveType.INT8));
  assertThat(exponent.presence(), is(Presence.CONSTANT));
  assertThat(exponent.constVal(), is(PrimitiveValue.parse("-2", PrimitiveType.INT8)));
  assertThat(decimal64.encodedLength(), is(8));
}
origin: real-logic/simple-binary-encoding

@Test
public void shouldHandleDecimal32CompositeType()
  throws Exception
{
  final String testXmlString =
    "<types>" +
    "<composite name=\"decimal32\">" +
    "    <type name=\"mantissa\" primitiveType=\"int32\"/>" +
    "    <type name=\"exponent\" primitiveType=\"int8\" presence=\"constant\">-2</type>" +
    "</composite>" +
    "</types>";
  final Map<String, Type> map = parseTestXmlWithMap("/types/composite", testXmlString);
  final CompositeType decimal32 = (CompositeType)map.get("decimal32");
  assertThat(decimal32.name(), is("decimal32"));
  final EncodedDataType mantissa = (EncodedDataType)decimal32.getType("mantissa");
  final EncodedDataType exponent = (EncodedDataType)decimal32.getType("exponent");
  assertThat(mantissa.primitiveType(), is(PrimitiveType.INT32));
  assertThat(exponent.primitiveType(), is(PrimitiveType.INT8));
  assertThat(exponent.presence(), is(Presence.CONSTANT));
  assertThat(exponent.constVal(), is(PrimitiveValue.parse("-2", PrimitiveType.INT8)));
  assertThat(decimal32.encodedLength(), is(4));
}
origin: uk.co.real-logic/sbe

/**
 * Construct a ValidValue given the XML node and the encodingType.
 *
 * @param node         that contains the validValue
 * @param encodingType for the enum
 */
public ValidValue(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"));
  checkForValidName(node, name);
}
origin: uk.co.real-logic/sbe-all

/**
 * Construct a ValidValue given the XML node and the encodingType.
 *
 * @param node         that contains the validValue
 * @param encodingType for the enum
 */
public ValidValue(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"));
  checkForValidName(node, name);
}
uk.co.real_logic.sbePrimitiveValueparse

Javadoc

Parse constant value string and set representation based on type, length, and characterEncoding

Popular methods of PrimitiveValue

  • longValue
    Return long value for this PrimitiveValue
  • size
    Return encodedLength for this PrimitiveValue for serialization purposes.
  • toString
    Return String representation of this object
  • <init>
    Construct and fill in value as a byte array.
  • byteArrayValue
    Return byte array value for this PrimitiveValue given a particular type
  • doubleValue
    Return double value for this PrimitiveValue.
  • representation
    Get the Representation of the value.
  • characterEncoding
    The character encoding of the byte array representation.

Popular in Java

  • Creating JSON documents from java classes using gson
  • putExtra (Intent)
  • getContentResolver (Context)
  • setScale (BigDecimal)
    Returns a BigDecimal whose scale is the specified value, and whose value is numerically equal to thi
  • BufferedImage (java.awt.image)
    The BufferedImage subclass describes an java.awt.Image with an accessible buffer of image data. All
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • LogFactory (org.apache.commons.logging)
    A minimal incarnation of Apache Commons Logging's LogFactory API, providing just the common Log look
  • Table (org.hibernate.mapping)
    A relational table
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now