Class ElementarySeg
- java.lang.Object
-
- com.automation_pros.odva.cip.path.PathSegment
-
- com.automation_pros.odva.cip.path.DataDefinitionSeg
-
- com.automation_pros.odva.cip.path.ElementarySeg
-
- All Implemented Interfaces:
java.lang.Comparable<PathSegment>
public class ElementarySeg 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 classElementarySeg.DecoderDecode bytes expected to contain one encoded path segment.-
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 booleanboolHostjava.lang.reflect.Constructor<?>constructorjava.lang.StringcrcNamejava.lang.Class<? extends BaseDataType<?>>elementaryClassprotected java.lang.String[]parseNamesprotected BaseDataType<?>sampleinttypeCode-
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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intalignment(DataContext ctx)Alignment is normally the natural size of a primitive element.protected BaseDataType<?>construct(int[] dimensions, DataContext ctx)Construct an instance of the type represented by this definition, using the given dimensions.booleanequals(java.lang.Object o)DecoratedDefSegfollow(PathSegment seg, DataContext ctx)Step into this type definition by the given selector, returning the inner type definition.DataDefinitionSeg.DataDefinitionFragmentfollowOffsets(java.lang.Integer outerByteOffset, PathSegment seg, DataContext ctx)Step into this type definition by the given selector, returning the inner type definition.intgetBytes()Obtain the number of bytes needed to encode this segment instance in packed format.java.lang.StringgetCrcName()java.lang.String[]getParseNames()BaseDataType<?>getSample()intgetSize(DataContext ctx, int... dims)Return the number of bytes occupied by the given data type.intgetSizeImpl(DataContext ctx)Return the number of bytes occupied by a single instance of the given data type.java.util.List<java.lang.String>getTokens()inthashCode()booleanisBoolHost()Some elementary data types (the integer and word types) can be hosts for named bits within structures.booleanisBoolImpl()Size calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.booleanisStringData()Mark string implementations for special handling.static java.util.List<ElementarySeg>known()static ElementarySeglookup(int segtype)static ElementarySeglookup(java.lang.Class<?> clazz)static ElementarySeglookup(java.lang.String token)static voidmain(java.lang.String[] args)protected DataDefinitionSeg.DataDefinitionFragmentmakeBitFragment(java.lang.Integer outerByteOffset, DataContext ctx)intmaxSize(DataContext ctx)Some data types need to offer a range of sizes for the encoded form of their data.intminSize(DataContext ctx)Some data types need to offer a range of sizes for the encoded form of their data.voidput(java.nio.ByteBuffer dest, boolean padded)Encode the current instance to the given destination.PathSegmentset(java.nio.ByteBuffer source, boolean padded)Replace the current instance content with the decoded source bytes.java.lang.StringsimpleString()Supply s simple descriptive name usable when browsing a hierarchy.-
Methods inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
browseInner, construct, fromClass, fromData, getPermItem, nestedMaxSize, nestedMinSize, nestedSize, nestedSizeImpl
-
Methods inherited from class com.automation_pros.odva.cip.path.PathSegment
compareTo, decode, decodeAll, getSegtype, getWords, hexString, mergeTokens, registerHandler, setSegtype, toString
-
-
-
-
Field Detail
-
typeCode
public final int typeCode
-
elementaryClass
public final java.lang.Class<? extends BaseDataType<?>> elementaryClass
-
constructor
public final java.lang.reflect.Constructor<?> constructor
-
sample
protected final BaseDataType<?> sample
-
crcName
public final java.lang.String crcName
-
parseNames
protected final java.lang.String[] parseNames
-
boolHost
protected final boolean boolHost
-
-
Method Detail
-
lookup
public static ElementarySeg lookup(java.lang.Class<?> clazz)
-
lookup
public static ElementarySeg lookup(java.lang.String token)
-
lookup
public static ElementarySeg lookup(int segtype)
-
known
public static java.util.List<ElementarySeg> known()
-
getSample
public BaseDataType<?> getSample()
-
isBoolHost
public boolean isBoolHost()
Description copied from class:DataDefinitionSegSome elementary data types (the integer and word types) can be hosts for named bits within structures. This method is overridden in the necessary places to support this. It corresponds to subclasses of BaseDataType that implement the BoolHost interface.- Overrides:
isBoolHostin classDataDefinitionSeg- Returns:
-
isStringData
public boolean isStringData()
Description copied from class:DataDefinitionSegMark string implementations for special handling.- Overrides:
isStringDatain classDataDefinitionSeg- Returns:
-
getSizeImpl
public int getSizeImpl(DataContext ctx)
Description copied from class:DataDefinitionSegReturn 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:
getSizeImplin classDataDefinitionSeg- Returns:
- Number of bytes.
-
minSize
public int minSize(DataContext ctx)
Description copied from class:DataDefinitionSegSome data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.- Overrides:
minSizein classDataDefinitionSeg- Returns:
-
maxSize
public int maxSize(DataContext ctx)
Description copied from class:DataDefinitionSegSome data types need to offer a range of sizes for the encoded form of their data. The common case is fixed.- Overrides:
maxSizein classDataDefinitionSeg- Returns:
-
alignment
public int alignment(DataContext ctx)
Description copied from class:DataDefinitionSegAlignment is normally the natural size of a primitive element. Structured types and variable length types must override this method.- Overrides:
alignmentin classDataDefinitionSeg- Returns:
-
isBoolImpl
public boolean isBoolImpl()
Description copied from class:DataDefinitionSegSize calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.- Overrides:
isBoolImplin classDataDefinitionSeg- Returns:
-
getSize
public int getSize(DataContext ctx, int... dims)
Description copied from class:DataDefinitionSegReturn the number of bytes occupied by the given data type. When the data is indirect (hosted elsewhere), or variable length, size is -1.When dimensions are provided, compute the bytes the complete array will occupy. Otherwise report the size of a singleton.
- Overrides:
getSizein classDataDefinitionSeg- Returns:
- Number of bytes.
-
construct
protected BaseDataType<?> construct(int[] dimensions, DataContext ctx)
Description copied from class:DataDefinitionSegConstruct 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:
constructin classDataDefinitionSeg- Returns:
-
getCrcName
public java.lang.String getCrcName()
-
simpleString
public java.lang.String simpleString()
Description copied from class:PathSegmentSupply 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:
simpleStringin classPathSegment- Returns:
-
getParseNames
public java.lang.String[] getParseNames()
-
set
public PathSegment set(java.nio.ByteBuffer source, boolean padded)
Description copied from class:PathSegmentReplace 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:
setin 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:PathSegmentEncode the current instance to the given destination.- Specified by:
putin classPathSegment- Parameters:
dest- The buffer receiving the complete encoded instance.padded- Alternate format selection. Packed format when false.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classPathSegment
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
getBytes
public int getBytes()
Description copied from class:PathSegmentObtain the number of bytes needed to encode this segment instance in packed format.- Specified by:
getBytesin classPathSegment- Returns:
- Number of bytes, assuming put() will be called with padded false.
-
getTokens
public java.util.List<java.lang.String> getTokens()
- Specified by:
getTokensin classPathSegment
-
main
public static void main(java.lang.String[] args)
-
follow
public DecoratedDefSeg follow(PathSegment seg, DataContext ctx)
Description copied from class:DataDefinitionSegStep into this type definition by the given selector, returning the inner type definition. Look up inner types with the given context.- Overrides:
followin classDataDefinitionSeg- Returns:
-
makeBitFragment
protected DataDefinitionSeg.DataDefinitionFragment makeBitFragment(java.lang.Integer outerByteOffset, DataContext ctx)
-
followOffsets
public DataDefinitionSeg.DataDefinitionFragment followOffsets(java.lang.Integer outerByteOffset, PathSegment seg, DataContext ctx)
Description copied from class:DataDefinitionSegStep into this type definition by the given selector, returning the inner type definition. Look up inner types with the given context. Deliver a null byteOffset if unknowable.- Overrides:
followOffsetsin classDataDefinitionSeg- Returns:
-
-