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 class
DecoratedDefSeg.Decoder
Decode 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.Pattern
constantDimension
protected int[]
dims
protected java.lang.String
documentation
protected DataDefinitionSeg
inner
protected java.lang.String
name
protected int[]
offsets
protected CipPath
variant
-
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 protected
DecoratedDefSeg()
DecoratedDefSeg(DataDefinitionSeg inner)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDimensionToken(java.lang.String dim)
int
alignment(DataContext ctx)
Alignment is normally the natural size of a primitive element.java.util.List<PathSegment>
browseInner(DataContext ctx)
int
compareTo(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.DecoratedDefSeg
dims(int[] dims)
DecoratedDefSeg
doc(java.lang.String documentation)
DecoratedDefSeg
duplicate()
boolean
equals(java.lang.Object o)
DecoratedDefSeg
follow(PathSegment seg, DataContext ctx)
Step into this type definition by the given selector, returning the inner type definition.protected DecoratedDefSeg
followIn()
Permit subclasses to substitute a new instance of themselves when following array subscripts.DataDefinitionSeg.DataDefinitionFragment
followOffsets(java.lang.Integer outerByteOffset, PathSegment seg, DataContext ctx)
Step into this type definition by the given selector, returning the inner type definition.int
getBytes()
Obtain the number of bytes needed to encode this segment instance in packed format.int[]
getDims()
java.lang.String
getDocumentation()
DataDefinitionSeg
getInner()
java.lang.String
getName()
int[]
getOffsets()
PermissionedItem
getPermItem()
Support permissions tracking as a general feature.int
getQty()
int
getSize(DataContext ctx, int... dims)
Return the number of bytes occupied by the given data type.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()
CipPath
getVariant()
int
hashCode()
boolean
isBoolHost()
Some elementary data types (the integer and word types) can be hosts for named bits within structures.boolean
isBoolImpl()
Size calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.boolean
isStringData()
Mark string implementations for special handling.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.DecoratedDefSeg
name(java.lang.String name)
int
nestedMaxSize(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.int
nestedMinSize(DataContext ctx)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.int
nestedSize(DataContext ctx, int... dims)
Certain types (Omron strings and booleans) can have different encodings when packed into structures.DecoratedDefSeg
offsets(int[] offsets)
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.void
setDims(int[] dims)
void
setDocumentation(java.lang.String documentation)
void
setName(java.lang.String name)
void
setOffsets(int[] offsets)
void
setVariant(CipPath variant)
java.lang.String
simpleString()
Supply s simple descriptive name usable when browsing a hierarchy.protected void
updateSegType()
DecoratedDefSeg
variant(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:DataDefinitionSeg
Some 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:
isBoolHost
in classDataDefinitionSeg
- Returns:
-
isBoolImpl
public boolean isBoolImpl()
Description copied from class:DataDefinitionSeg
Size calculations for boolean min and max must defer to .getSize() to get the right answer for boolean arrays.- Overrides:
isBoolImpl
in classDataDefinitionSeg
- Returns:
-
isStringData
public boolean isStringData()
Description copied from class:DataDefinitionSeg
Mark string implementations for special handling.- Overrides:
isStringData
in classDataDefinitionSeg
- Returns:
-
getSizeImpl
public 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:
-
getSize
public int getSize(DataContext ctx, int... dims)
Description copied from class:DataDefinitionSeg
Return 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:
getSize
in classDataDefinitionSeg
- Returns:
- Number of bytes.
-
nestedMinSize
public int nestedMinSize(DataContext ctx)
Description copied from class:DataDefinitionSeg
Certain types (Omron strings and booleans) can have different encodings when packed into structures.- Overrides:
nestedMinSize
in classDataDefinitionSeg
-
nestedMaxSize
public int nestedMaxSize(DataContext ctx)
Description copied from class:DataDefinitionSeg
Certain types (Omron strings and booleans) can have different encodings when packed into structures.- Overrides:
nestedMaxSize
in classDataDefinitionSeg
-
nestedSize
public int nestedSize(DataContext ctx, int... dims)
Description copied from class:DataDefinitionSeg
Certain types (Omron strings and booleans) can have different encodings when packed into structures.- Overrides:
nestedSize
in 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:
browseInner
in 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: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:
-
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
-
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:
-
compareTo
public int compareTo(PathSegment o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<PathSegment>
- Overrides:
compareTo
in classPathSegment
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classPathSegment
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
duplicate
public DecoratedDefSeg duplicate()
-
getPermItem
public PermissionedItem getPermItem()
Description copied from class:DataDefinitionSeg
Support permissions tracking as a general feature. This is overridden where appropriate.- Overrides:
getPermItem
in 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:DataDefinitionSeg
Step into this type definition by the given selector, returning the inner type definition. Look up inner types with the given context.- Overrides:
follow
in classDataDefinitionSeg
- Returns:
-
followOffsets
public DataDefinitionSeg.DataDefinitionFragment followOffsets(java.lang.Integer outerByteOffset, PathSegment seg, DataContext ctx)
Description copied from class:DataDefinitionSeg
Step 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:
followOffsets
in classDataDefinitionSeg
- Returns:
-
-