/** * Get the original value (if possible) or the regular value if the original value does not exist. * @param key the key to return * @return the value of the key */ public String getOriginalValue(final String key) { String value = get(Attributes.ORIGINAL_VALUE_MARKER + key); if (value != null) { return value; } return get(key); } }
public String output(final int offset) { return "(" + attributes.toString() + ")"; }
public ControlAttributes() { attributes = new Attributes(); }
@SuppressWarnings("ConstantConditions") public void resolveParameters(@Nonnull final Attributes attributes) { List<Parameter> entrySet = getParameterSet(); for (Parameter entry : entrySet) { String key = entry.getKey(); String value = entry.getValue(); // first check the given attributes and then check our own if (attributes.isSet(key)) { set(value, controlParameter.applyParameter(entry.getOriginalValue(), entry.getKey(), attributes.get(key))); } else if (isSet(key) && !isParameterDefinition(get(key))) { set(value, get(key)); } else { remove(value); } } }
public void setPost(@Nonnull final String post) { attributes.set("post", post); }
@Nonnull public List<Parameter> extractParameters() { List<Parameter> parameters = new ArrayList<Parameter>(); for (Map.Entry < String, String > entry : attributes.entrySet()) { String key = entry.getKey(); // like key="$value" String value = entry.getValue(); if (isParameterDefinition(value)) { parameters.add(new Parameter(value, controlParameter.extractParameter(value), key)); } } return parameters; }
private boolean getInherit(@Nonnull final Attributes attributes) { return attributes.getAsBoolean("inherit", DEFAULT_INHERIT); }
public void removeWithTag(final String tag) { Set < String > tagged = taggedAttributes.get(tag); if (tagged != null) { for (String key : tagged) { remove(key); } } }
@Override public void applyAttributes(@Nonnull final Attributes attributes) { this.attributes.overwrite(attributes); } }
public boolean containsTimeValues() { if (values.isEmpty()) { return false; } for (Attributes p : values) { if (p.isSet("time")) { return true; } } return false; } }
@Nonnull List<Parameter> getParameterSet() { return extractParameters(); }
/** * Set an attribute. * * @param name name of the attribute to set * @param value value to set attribute to */ public void set(@Nonnull final String name, @Nonnull final String value) { setAttribute(name, value); }
private int getHotspotY() { return getAttributes().getAsInteger("hotspotY", 0); } }
public StyleBuilder id(@Nonnull final String id) { styleAttributes.set("id", id); return this; }
/** * Check if a specific attribute is set. * * @param name the name of the attribute * @return {@code true} in case a attribute with the supplied name exists */ public boolean isSet(@Nonnull final String name) { return get(name) != null; }
public XmlBaseType() { attributes = new Attributes(); }
private boolean getPost(@Nonnull final Attributes attributes) { return attributes.getAsBoolean("post", DEFAULT_POST); }
public StyleBuilder base(@Nonnull final String baseStyle) { styleAttributes.set("base", baseStyle); return this; }
@Nonnull public String getWithDefault(@Nonnull final String name, @Nonnull final String defaultValue) { String value = get(name); if (value == null) { value = defaultValue; } return value; }
public void setWrap(final boolean wrap) { getAttributes().set("wrap", wrap ? "true" : "false"); } }