Class Tools
- java.lang.Object
-
- de.iip_ecosphere.platform.support.aas.basyx.Tools
-
public class Tools extends java.lang.ObjectSome utilities, such as for parameter checking. Public for testing.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.Map<de.iip_ecosphere.platform.support.aas.AssetKind,org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind>ASSETKINDS2BASYXprivate static java.util.Map<org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind,de.iip_ecosphere.platform.support.aas.AssetKind>BASYX2ASSETKINDSprivate static java.util.Map<org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType,de.iip_ecosphere.platform.support.aas.Type>BASYX2TYPESprivate static java.util.Map<de.iip_ecosphere.platform.support.aas.Type,org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType>TYPES2BASYX
-
Constructor Summary
Constructors Constructor Description Tools()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringcheckId(java.lang.String idShort)Checks a given short id for not being empty.static java.lang.StringcheckUrn(java.lang.String urn)Checks a given URN for not being empty.private static java.lang.Stringcompose(java.lang.String prefix, java.lang.String value, boolean stripPrefix)Composes a prefix and a value if desired.(package private) static voiddisposeTomcatWorkingDir(java.io.File baseDir, int port)Tries to dispose a Tomcat working directory.static <E extends java.lang.Enum<E>>
EgetOption(java.lang.String[] options, E dflt, java.lang.Class<E> cls)Tests the values inpptionsagainst the constants inclsand returns a matching constant ordflt.static org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueTypegetType(org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement elt)Returns the value type of a submodel element.(package private) static java.lang.StringidToUrlPath(java.lang.String id)Turns an id into a URL path.private static voidmapKind(de.iip_ecosphere.platform.support.aas.AssetKind kind, org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind basyxKind)Maps an implementation-independent asset kind into a BaSyx asset kind.private static voidmapType(de.iip_ecosphere.platform.support.aas.Type type, org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType basyxType)Maps an implementation-independent type into a BaSyx property-value type.static org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKindtranslate(de.iip_ecosphere.platform.support.aas.AssetKind kind)Translates a implementation-independent asset kind to an implementation-specific asset kind.static org.eclipse.basyx.submodel.metamodel.map.qualifier.LangStringtranslate(de.iip_ecosphere.platform.support.aas.LangString ls)Translates an AAS to a BaSyx lang string.static org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueTypetranslate(de.iip_ecosphere.platform.support.aas.Type type)Translates a implementation-independent type to an implementation-specific type.static de.iip_ecosphere.platform.support.aas.AssetKindtranslate(org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind kind)Translates a implementation-specific asset kind to an implementation-independent asset kind.static de.iip_ecosphere.platform.support.aas.LangStringtranslate(org.eclipse.basyx.submodel.metamodel.map.qualifier.LangString ls)Translates BaSyx lang string to an AAS lang string.static de.iip_ecosphere.platform.support.aas.Typetranslate(org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType type)Translates a implementation-specific type to an implementation-independent type.static org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifiertranslateIdentifier(java.lang.String id, java.lang.String dfltCustom)Translates an identifier.static java.lang.StringtranslateIdentifier(org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier identifier)Translates an identifier back into its string notation.static org.eclipse.basyx.submodel.metamodel.api.reference.IReferencetranslateReference(java.lang.String id)Translates a reference.static java.lang.StringtranslateReference(org.eclipse.basyx.submodel.metamodel.api.reference.IReference ref, boolean stripPrefix)Translates a reference back to its string format.static java.lang.ObjecttranslateValueFromBaSyx(java.lang.Object val, org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType type)Translates a BaSyx value back.static java.lang.ObjecttranslateValueToBaSyx(org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType type, java.lang.Object value)Translates a value for a given target type.
-
-
-
Field Detail
-
TYPES2BASYX
private static final java.util.Map<de.iip_ecosphere.platform.support.aas.Type,org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType> TYPES2BASYX
-
BASYX2TYPES
private static final java.util.Map<org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType,de.iip_ecosphere.platform.support.aas.Type> BASYX2TYPES
-
ASSETKINDS2BASYX
private static final java.util.Map<de.iip_ecosphere.platform.support.aas.AssetKind,org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind> ASSETKINDS2BASYX
-
BASYX2ASSETKINDS
private static final java.util.Map<org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind,de.iip_ecosphere.platform.support.aas.AssetKind> BASYX2ASSETKINDS
-
-
Method Detail
-
mapType
private static void mapType(de.iip_ecosphere.platform.support.aas.Type type, org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType basyxType)Maps an implementation-independent type into a BaSyx property-value type.- Parameters:
type- the implementation-independent typebasyxType- the corresponding BaSyx property-value type
-
mapKind
private static void mapKind(de.iip_ecosphere.platform.support.aas.AssetKind kind, org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind basyxKind)Maps an implementation-independent asset kind into a BaSyx asset kind.- Parameters:
kind- the implementation-independent asset kindbasyxKind- the corresponding BaSyx asset kind
-
checkUrn
public static java.lang.String checkUrn(java.lang.String urn)
Checks a given URN for not being empty.- Parameters:
urn- the URN- Returns:
urn- Throws:
java.lang.IllegalArgumentException- if the urn is empty or null
-
checkId
public static java.lang.String checkId(java.lang.String idShort)
Checks a given short id for not being empty.- Parameters:
idShort- the short id- Returns:
idShort- Throws:
java.lang.IllegalArgumentException- if the id is empty or null
-
translate
public static org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType translate(de.iip_ecosphere.platform.support.aas.Type type)
Translates a implementation-independent type to an implementation-specific type.- Parameters:
type- the implementation-independent type- Returns:
- the implementation-specific type
-
translate
public static de.iip_ecosphere.platform.support.aas.Type translate(org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType type)
Translates a implementation-specific type to an implementation-independent type.- Parameters:
type- the implementation-specific type- Returns:
- the implementation-independent type
-
translate
public static org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind translate(de.iip_ecosphere.platform.support.aas.AssetKind kind)
Translates a implementation-independent asset kind to an implementation-specific asset kind.- Parameters:
kind- the implementation-independent asset kind- Returns:
- the implementation-specific asset kind
-
translate
public static de.iip_ecosphere.platform.support.aas.AssetKind translate(org.eclipse.basyx.aas.metamodel.api.parts.asset.AssetKind kind)
Translates a implementation-specific asset kind to an implementation-independent asset kind.- Parameters:
kind- the implementation-specific asset kind- Returns:
- the implementation-independent asset kind
-
idToUrlPath
static java.lang.String idToUrlPath(java.lang.String id)
Turns an id into a URL path.- Parameters:
id- the id- Returns:
- the URL path
-
translateIdentifier
public static org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier translateIdentifier(java.lang.String id, java.lang.String dfltCustom)Translates an identifier. (supports URN and custom ids)- Parameters:
id- the id showing some form of type, e.g., prefix "urn:", may be empty or null leading to a custom identifier based ondfltCustomdfltCustom- the default value if id cannot be used- Returns:
- the identifier
-
translateIdentifier
public static java.lang.String translateIdentifier(org.eclipse.basyx.submodel.metamodel.api.identifier.IIdentifier identifier)
Translates an identifier back into its string notation.- Parameters:
identifier- the identifier (may be null, result is also null then)- Returns:
- the string notation
-
translateReference
public static org.eclipse.basyx.submodel.metamodel.api.reference.IReference translateReference(java.lang.String id)
Translates a reference. (supports IRDI, IRI)- Parameters:
id- the for declaring the reference showing some form of type, e.g., prefix "irdi:", may be empty or null leading to null, seeIdentifierType- Returns:
- the reference or null
-
translateReference
public static java.lang.String translateReference(org.eclipse.basyx.submodel.metamodel.api.reference.IReference ref, boolean stripPrefix)Translates a reference back to its string format. (supports IRDI, IRI)- Parameters:
ref- the reference to translate backstripPrefix- whether the prefix shall be included- Returns:
- the translated reference or null if
refwas null or it cannot be translated
-
compose
private static java.lang.String compose(java.lang.String prefix, java.lang.String value, boolean stripPrefix)Composes a prefix and a value if desired.- Parameters:
prefix- the prefixvalue- the valuestripPrefix- whether the prefix shall be included- Returns:
valueorprefix+value
-
getOption
public static <E extends java.lang.Enum<E>> E getOption(java.lang.String[] options, E dflt, java.lang.Class<E> cls)Tests the values inpptionsagainst the constants inclsand returns a matching constant ordflt.- Type Parameters:
E- the enum type- Parameters:
options- the options to checkdflt- the default valuecls- the enum class providing the constants- Returns:
- the matching option or
dflt
-
disposeTomcatWorkingDir
static void disposeTomcatWorkingDir(java.io.File baseDir, int port)Tries to dispose a Tomcat working directory.- Parameters:
baseDir- the basic directory where the working directory is located in, may be null for default, i.e., program home directoryport- the port number of the disposed Tomcat instance
-
translate
public static org.eclipse.basyx.submodel.metamodel.map.qualifier.LangString translate(de.iip_ecosphere.platform.support.aas.LangString ls)
Translates an AAS to a BaSyx lang string.- Parameters:
ls- the AAS lang string- Returns:
- the BaSyx lang string
-
translate
public static de.iip_ecosphere.platform.support.aas.LangString translate(org.eclipse.basyx.submodel.metamodel.map.qualifier.LangString ls)
Translates BaSyx lang string to an AAS lang string.- Parameters:
ls- the BaSyx lang string- Returns:
- the AAS lang string
-
translateValueToBaSyx
public static java.lang.Object translateValueToBaSyx(org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType type, java.lang.Object value)Translates a value for a given target type.- Parameters:
type- the BaSyx typevalue- the value to translate- Returns:
- the translated value
-
translateValueFromBaSyx
public static java.lang.Object translateValueFromBaSyx(java.lang.Object val, org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType type)Translates a BaSyx value back.- Parameters:
val- the value to be translatedtype- the expected target type to support the translation, may be null- Returns:
- the translated value
-
getType
public static org.eclipse.basyx.submodel.metamodel.map.submodelelement.dataelement.property.valuetype.ValueType getType(org.eclipse.basyx.submodel.metamodel.api.submodelelement.ISubmodelElement elt)
Returns the value type of a submodel element.- Parameters:
elt- the element- Returns:
- the value type or null if not available
-
-