Package adams.core.tags
Class TagProcessorHelper
- java.lang.Object
-
- adams.core.tags.TagProcessorHelper
-
public class TagProcessorHelper extends Object
Helper class forTagProcessor
classes.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description TagProcessorHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static void
addToMap(Map<String,BaseKeyValuePair> map, BaseKeyValuePair[] tags, boolean override)
Adds the tags to the map.protected static void
addToMap(Map<String,BaseKeyValuePair> map, List<BaseKeyValuePair> tags, boolean override)
Adds the tags to the map.static List<BaseKeyValuePair>
getAllTags(TagHandler handler)
Retrieves all tags from the tag handler,.static List<BaseKeyValuePair>
getAllTags(Actor actor, boolean traverse)
Retrieves all tags from the actor, going up in the actor tree, with lower ones overriding ones defined higher up.static List<BaseKeyValuePair>
getAllTags(Node node, boolean traverse)
Retrieves all tags from the actor, going up in the actor tree, with lower ones overriding ones defined higher up.static boolean
getTagBoolean(Object obj, String tag, boolean defValue)
Returns the value of the tag if present, otherwise the default value.static boolean
getTagBoolean(Object obj, String tag, boolean defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.static byte
getTagByte(Object obj, String tag, byte defValue)
Returns the value of the tag if present, otherwise the default value.static byte
getTagByte(Object obj, String tag, byte defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.static double
getTagDouble(Object obj, String tag, double defValue)
Returns the value of the tag if present, otherwise the default value.static double
getTagDouble(Object obj, String tag, double defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.static float
getTagFloat(Object obj, String tag, float defValue)
Returns the value of the tag if present, otherwise the default value.static float
getTagFloat(Object obj, String tag, float defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.static int
getTagInt(Object obj, String tag, int defValue)
Returns the value of the tag if present, otherwise the default value.static int
getTagInt(Object obj, String tag, int defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.static long
getTagLong(Object obj, String tag, long defValue)
Returns the value of the tag if present, otherwise the default value.static long
getTagLong(Object obj, String tag, long defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.static String
getTagString(Object obj, String tag, String defValue)
Returns the value of the tag if present, otherwise the default value.static String
getTagString(Object obj, String tag, String defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.protected static String
getTagValue(Object obj, String tag, Variables vars)
Returns the value of the tag if present.static boolean
hasTag(Object obj, String tag)
Checks whether the specified tag is present.
-
-
-
Method Detail
-
hasTag
public static boolean hasTag(Object obj, String tag)
Checks whether the specified tag is present.- Parameters:
obj
- the object to checktag
- the tag to look for- Returns:
- true if the object supports tags and the tag is present
-
getTagValue
protected static String getTagValue(Object obj, String tag, Variables vars)
Returns the value of the tag if present.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look forvars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise null (eg if the object is not a tag handler or the tag is not present)
-
getTagString
public static String getTagString(Object obj, String tag, String defValue)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default value- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagString
public static String getTagString(Object obj, String tag, String defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default valuevars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagBoolean
public static boolean getTagBoolean(Object obj, String tag, boolean defValue)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default value- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagBoolean
public static boolean getTagBoolean(Object obj, String tag, boolean defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default valuevars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagByte
public static byte getTagByte(Object obj, String tag, byte defValue)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default value- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagByte
public static byte getTagByte(Object obj, String tag, byte defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default valuevars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagInt
public static int getTagInt(Object obj, String tag, int defValue)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default value- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagInt
public static int getTagInt(Object obj, String tag, int defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default valuevars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagLong
public static long getTagLong(Object obj, String tag, long defValue)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default value- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagLong
public static long getTagLong(Object obj, String tag, long defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default valuevars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagFloat
public static float getTagFloat(Object obj, String tag, float defValue)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default value- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagFloat
public static float getTagFloat(Object obj, String tag, float defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default valuevars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagDouble
public static double getTagDouble(Object obj, String tag, double defValue)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default value- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getTagDouble
public static double getTagDouble(Object obj, String tag, double defValue, Variables vars)
Returns the value of the tag if present, otherwise the default value.- Parameters:
obj
- the object to obtain the tag value fromtag
- the tag to look fordefValue
- the default valuevars
- the variables to use, ignored if null- Returns:
- the associated value, otherwise the default value (eg if the object is not a tag handler or the tag is not present)
-
getAllTags
public static List<BaseKeyValuePair> getAllTags(TagHandler handler)
Retrieves all tags from the tag handler,.- Parameters:
handler
- the tag handler- Returns:
- all tags
-
addToMap
protected static void addToMap(Map<String,BaseKeyValuePair> map, List<BaseKeyValuePair> tags, boolean override)
Adds the tags to the map.- Parameters:
map
- the map for storing the tags (using their key as the map's key)tags
- the tags to addoverride
- if true, then existing tags can be replaced; otherwise only non-existing tags get added
-
addToMap
protected static void addToMap(Map<String,BaseKeyValuePair> map, BaseKeyValuePair[] tags, boolean override)
Adds the tags to the map.- Parameters:
map
- the map for storing the tags (using their key as the map's key)tags
- the tags to addoverride
- if true, then existing tags can be replaced; otherwise only non-existing tags get added
-
getAllTags
public static List<BaseKeyValuePair> getAllTags(Actor actor, boolean traverse)
Retrieves all tags from the actor, going up in the actor tree, with lower ones overriding ones defined higher up.- Parameters:
actor
- the actor to starttraverse
- whether to traverse upwards or not traverse at all- Returns:
- all tags
-
getAllTags
public static List<BaseKeyValuePair> getAllTags(Node node, boolean traverse)
Retrieves all tags from the actor, going up in the actor tree, with lower ones overriding ones defined higher up.- Parameters:
node
- the actor to starttraverse
- whether to traverse upwards or not traverse at all- Returns:
- all tags
-
-