Class DecoratedDefSeg
- java.lang.Object
-
- com.automation_pros.odva.cip.path.PathSegment
-
- com.automation_pros.odva.cip.path.DataDefinitionSeg
-
- com.automation_pros.odva.cip.path.DecoratedDefSeg
-
- All Implemented Interfaces:
java.lang.Comparable<PathSegment>
- Direct Known Subclasses:
StructMember.MemberTypeSegment
public class DecoratedDefSeg extends DataDefinitionSeg
Implements array dimensions for both standalone types and structure members, plus names for the latter.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDecoratedDefSeg.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 static java.util.regex.PatternconstantDimensionprotected int[]dimsprotected java.lang.Stringdocumentationprotected DataDefinitionSeginnerprotected java.lang.Stringnameprotected int[]offsetsprotected CipPathvariant-
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 protectedDecoratedDefSeg()DecoratedDefSeg(DataDefinitionSeg inner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDimensionToken(java.lang.String dim)intalignment(DataContext ctx)Alignment is normally the natural size of a primitive element.java.util.List<PathSegment>browseInner(DataContext ctx)intcompareTo(PathSegment o)protected int[]concatDimensions(int[] outer)protected int[]concatOffsets(int[] outer)protected BaseDataType<?>construct(int[] dimensions, DataContext ctx)Construct an instance of the type represented by this definition, using the given dimensions.DecoratedDefSegdims(int[] dims)DecoratedDefSegdoc(java.lang.String documentation)DecoratedDefSegduplicate()booleanequals(java.lang.Object o)DecoratedDefSegfollow(PathSegment seg, DataContext ctx)Step into this type definition by the given selector, returning the inner type definition.protected DecoratedDefSegfollowIn()Permit subclasses to substitute a new instance of themselves when following array subscripts.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.int[]getDims()java.lang.StringgetDocumentation()DataDefinitionSeggetInner()java.lang.StringgetName()int[]getOffsets()PermissionedItemgetPermItem()Support permissions tracking as a general feature.intgetQty()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()CipPathgetVariant()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.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.DecoratedDefSegname(java.lang.String name)intnestedMaxSize(DataContext ctx)Certain types (Omron strings and booleans) can have different encodings when packed into structures.intnestedMinSize(DataContext ctx)Certain types (Omron strings and booleans) can have different encodings when packed into structures.intnestedSize(DataContext ctx, int... dims)Certain types (Omron strings and booleans) can have different encodings when packed into structures.DecoratedDefSegoffsets(int[] offsets)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.voidsetDims(int[] dims)voidsetDocumentation(java.lang.String documentation)voidsetName(java.lang.String name)voidsetOffsets(int[] offsets)voidsetVariant(CipPath variant)java.lang.StringsimpleString()Supply s simple descriptive name usable when browsing a hierarchy.protected voidupdateSegType()DecoratedDefSegvariant(CipPath variant)-
Methods inherited from class com.automation_pros.odva.cip.path.DataDefinitionSeg
construct, fromClass, fromData, nestedSizeImpl
-
Methods inherited from class com.automation_pros.odva.cip.path.PathSegment
decode, decodeAll, getSegtype, getWords, hexString, mergeTokens, registerHandler, setSegtype, toString
-
-
-
-
Field Detail
-
constantDimension
public static final java.util.regex.Pattern constantDimension
-
inner
protected DataDefinitionSeg inner
-
name
protected java.lang.String name
-
dims
protected int[] dims
-
offsets
protected int[] offsets
-
variant
protected CipPath variant
-
documentation
protected java.lang.String documentation
-
-
Constructor Detail
-
DecoratedDefSeg
protected DecoratedDefSeg()
-
DecoratedDefSeg
public DecoratedDefSeg(DataDefinitionSeg inner)
-
-
Method Detail
-
getDocumentation
public java.lang.String getDocumentation()
-
setDocumentation
public void setDocumentation(java.lang.String documentation)
-
doc
public DecoratedDefSeg doc(java.lang.String documentation)
-
updateSegType
protected void updateSegType()
-
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:
-
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:
-
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:
-
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.
-
nestedMinSize
public int nestedMinSize(DataContext ctx)
Description copied from class:DataDefinitionSegCertain types (Omron strings and booleans) can have different encodings when packed into structures.- Overrides:
nestedMinSizein classDataDefinitionSeg
-
nestedMaxSize
public int nestedMaxSize(DataContext ctx)
Description copied from class:DataDefinitionSegCertain types (Omron strings and booleans) can have different encodings when packed into structures.- Overrides:
nestedMaxSizein classDataDefinitionSeg
-
nestedSize
public int nestedSize(DataContext ctx, int... dims)
Description copied from class:DataDefinitionSegCertain types (Omron strings and booleans) can have different encodings when packed into structures.- Overrides:
nestedSizein classDataDefinitionSeg
-
getInner
public DataDefinitionSeg getInner()
-
getDims
public int[] getDims()
-
setDims
public void setDims(int[] dims)
-
dims
public DecoratedDefSeg dims(int[] dims)
-
getQty
public int getQty()
-
getVariant
public CipPath getVariant()
-
setVariant
public void setVariant(CipPath variant)
-
variant
public DecoratedDefSeg variant(CipPath variant)
-
getOffsets
public int[] getOffsets()
-
setOffsets
public void setOffsets(int[] offsets)
-
offsets
public DecoratedDefSeg offsets(int[] offsets)
-
browseInner
public java.util.List<PathSegment> browseInner(DataContext ctx)
- Overrides:
browseInnerin classDataDefinitionSeg
-
getName
public java.lang.String getName()
-
setName
public void setName(java.lang.String name)
-
name
public DecoratedDefSeg name(java.lang.String name)
-
addDimensionToken
public void addDimensionToken(java.lang.String dim)
-
concatDimensions
protected int[] concatDimensions(int[] outer)
-
concatOffsets
protected int[] concatOffsets(int[] outer)
-
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:
-
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.
-
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
-
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:
-
compareTo
public int compareTo(PathSegment o)
- Specified by:
compareToin interfacejava.lang.Comparable<PathSegment>- Overrides:
compareToin classPathSegment
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classPathSegment
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
duplicate
public DecoratedDefSeg duplicate()
-
getPermItem
public PermissionedItem getPermItem()
Description copied from class:DataDefinitionSegSupport permissions tracking as a general feature. This is overridden where appropriate.- Overrides:
getPermItemin classDataDefinitionSeg- Returns:
-
followIn
protected DecoratedDefSeg followIn()
Permit subclasses to substitute a new instance of themselves when following array subscripts.- Returns:
- A new instance with the same inner segment and no other attributes.
-
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:
-
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:
-
-