Class OmStringDefSeg
- java.lang.Object
-
- com.automation_pros.odva.cip.path.PathSegment
-
- com.automation_pros.odva.cip.path.DataDefinitionSeg
-
- com.automation_pros.odva.cip.path.OmStringDefSeg
-
- All Implemented Interfaces:
java.lang.Comparable<PathSegment>
public class OmStringDefSeg extends DataDefinitionSeg
Encapsulates an elementary data type annotation within a CIP Path definition. Type annotations are generally not passed on the wire, but delimit the path fragment that will go on the wire (before the data type) from the path fragment that will be applied to the payload on the wire.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
OmStringDefSeg.Decoder
Decode bytes expected to contain one encoded path segment.static class
OmStringDefSeg.Parser
Registered as "omstring".-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
DataDefinitionSeg.DataDefinitionFragment
-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.path.PathSegment
PathSegment.HasAlternateHex
-
-
Field Summary
Fields Modifier and Type Field Description protected int
allocation
protected boolean
locked
-
Fields inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
sLogger
-
Fields inherited from class com.automation_pros.odva.cip.path.PathSegment
identifierChars, segtype
-
-
Constructor Summary
Constructors Modifier Constructor Description OmStringDefSeg()
protected
OmStringDefSeg(int allocation)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
alignment(DataContext ctx)
Alignment is normally the natural size of a primitive element.int
compareTo(PathSegment o)
protected BaseDataType<?>
construct(int[] dimensions, DataContext ctx)
Construct an instance of the type represented by this definition, using the given dimensions.int
getAllocation()
int
getBytes()
Obtain the number of bytes needed to encode this segment instance in packed format.static OmStringDefSeg
getCached(int allocation)
protected int
getSizeImpl(DataContext ctx)
Return the number of bytes occupied by a single instance of the given data type.java.util.List<java.lang.String>
getTokens()
boolean
isStringData()
Mark string implementations for special handling.OmStringDefSeg
lock()
int
maxSize(DataContext ctx)
Some data types need to offer a range of sizes for the encoded form of their data.int
minSize(DataContext ctx)
Some data types need to offer a range of sizes for the encoded form of their data.void
put(java.nio.ByteBuffer dest, boolean padded)
Encode the current instance to the given destination.PathSegment
set(java.nio.ByteBuffer source, boolean padded)
Replace the current instance content with the decoded source bytes.java.lang.String
simpleString()
Supply s simple descriptive name usable when browsing a hierarchy.-
Methods inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
browseInner, construct, follow, followOffsets, fromClass, fromData, getPermItem, getSize, isBoolHost, isBoolImpl, nestedMaxSize, nestedMinSize, nestedSize, nestedSizeImpl
-
Methods inherited from class com.automation_pros.odva.cip.path.PathSegment
decode, decodeAll, equals, getSegtype, getWords, hexString, mergeTokens, registerHandler, setSegtype, toString
-
-
-
-
Method Detail
-
getCached
public static OmStringDefSeg getCached(int allocation)
-
lock
public OmStringDefSeg lock()
-
getAllocation
public int getAllocation()
-
isStringData
public boolean isStringData()
Description copied from class:DataDefinitionSeg
Mark string implementations for special handling.- Overrides:
isStringData
in classDataDefinitionSeg
- Returns:
-
getSizeImpl
protected int getSizeImpl(DataContext ctx)
Description copied from class:DataDefinitionSeg
Return the number of bytes occupied by a single instance of the given data type. When the data is indirect, size is zero. When the data is variable length, size is -1;- Specified by:
getSizeImpl
in classDataDefinitionSeg
- Returns:
- Number of bytes.
-
minSize
public int minSize(DataContext ctx)
Description copied from class:DataDefinitionSeg
Some data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.- Overrides:
minSize
in classDataDefinitionSeg
- Returns:
-
maxSize
public int maxSize(DataContext ctx)
Description copied from class:DataDefinitionSeg
Some data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.- Overrides:
maxSize
in classDataDefinitionSeg
- Returns:
-
alignment
public int alignment(DataContext ctx)
Description copied from class:DataDefinitionSeg
Alignment is normally the natural size of a primitive element. Structured types and variable length types must override this method.- Overrides:
alignment
in classDataDefinitionSeg
- Returns:
-
construct
protected BaseDataType<?> construct(int[] dimensions, DataContext ctx)
Description copied from class:DataDefinitionSeg
Construct an instance of the type represented by this definition, using the given dimensions. This is an implementation detail that permits a DecoratedDefSeg to create arrays.Use the provided context to look up any ambiguous data types.
- Specified by:
construct
in classDataDefinitionSeg
- Returns:
-
compareTo
public int compareTo(PathSegment o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<PathSegment>
- Overrides:
compareTo
in classPathSegment
-
simpleString
public java.lang.String simpleString()
Description copied from class:PathSegment
Supply s simple descriptive name usable when browsing a hierarchy. A simple type name for elementary types, a non-detailed description for complex types.- Specified by:
simpleString
in classPathSegment
- Returns:
-
set
public PathSegment set(java.nio.ByteBuffer source, boolean padded)
Description copied from class:PathSegment
Replace the current instance content with the decoded source bytes.The caller must ensure that the instance is appropriate for the bytes supplied. This permits instance re-use in optimized applications.
- Specified by:
set
in classPathSegment
- Parameters:
source
- The bytes to be decoded. The position will be left after the last byte of the decoded segment.padded
- Alternate format selection. Packed format when false.- Returns:
- The same instance.
-
put
public void put(java.nio.ByteBuffer dest, boolean padded)
Description copied from class:PathSegment
Encode the current instance to the given destination.- Specified by:
put
in classPathSegment
- Parameters:
dest
- The buffer receiving the complete encoded instance.padded
- Alternate format selection. Packed format when false.
-
getBytes
public int getBytes()
Description copied from class:PathSegment
Obtain the number of bytes needed to encode this segment instance in packed format.- Specified by:
getBytes
in classPathSegment
- Returns:
- Number of bytes, assuming put() will be called with padded false.
-
getTokens
public java.util.List<java.lang.String> getTokens()
- Specified by:
getTokens
in classPathSegment
-
-