public StyleSpecification(QName name, String value) { this(new ComparableQName(name), value); }
public int compareTo(ComparableQName other) { String ns1 = getNamespaceURI(); String ns2 = other.getNamespaceURI(); if ((ns1 == null) && (ns2 != null)) return -1; else if ((ns1 != null) && (ns2 == null)) return 1; else if ((ns1 != null) && (ns2 != null)) { int d = ns1.compareTo(ns2); if (d != 0) return d; } String n1 = getLocalPart(); String n2 = other.getLocalPart(); return n1.compareTo(n2); }
public int compareTo(StyleSpecification other) { int d = name.compareTo(other.name); return (d != 0) ? d : value.compareTo(other.value); }
private static void recordDefaultedParameter(Model model, Object content, QName parameterName, Locator locator, VerifierContext context) { Map<QName,String> otherAttributes = Annotations.getOtherAttributes(content); Set<ComparableQName> defaulted = ComparableQName.parseNames(otherAttributes.get(defaultedParametersAttributeName)); ComparableQName pn = new ComparableQName(parameterName); if (!defaulted.contains(pn)) { defaulted.add(pn); otherAttributes.put(defaultedParametersAttributeName, ComparableQName.toString(defaulted)); } }
@Override public int hashCode() { int hc = 23; hc = hc * 31 + name.hashCode(); hc = hc * 31 + value.hashCode(); return hc; }
@Override public boolean equals(Object o) { if (o instanceof StyleSpecification) { StyleSpecification other = (StyleSpecification) o; if (!name.equals(other.name)) return false; else if (!value.equals(other.value)) return false; else return true; } else return false; }
public static final String toString(Set<ComparableQName> names) { StringBuffer sb = new StringBuffer(); for (ComparableQName qn : names) { if (sb.length() > 0) sb.append(' '); sb.append(qn.toString()); } return sb.toString(); }
public static final boolean isParameterDefaulted(Object content, QName name) { Map<QName,String> otherAttributes = Annotations.getOtherAttributes(content); Set<ComparableQName> defaulted = ComparableQName.parseNames(otherAttributes.get(defaultedParametersAttributeName)); return defaulted.contains(name); }
private static void generateAttributes(StyleSet ss, Element e) { String id = ss.getId(); if ((id != null) && !id.isEmpty()) { for (StyleSpecification s : ss.getStyles().values()) { ComparableQName n = s.getName(); e.setAttributeNS(n.getNamespaceURI(), n.getLocalPart(), s.getValue()); } e.setAttributeNS(XML.xmlNamespace, "id", id); } }
public StyleSpecification(String nsUri, String localName, String value) { this(new ComparableQName(nsUri, localName), value); }
private static void generateAttributes(StyleSet ss, Element elt) { String id = ss.getId(); if ((id != null) && !id.isEmpty()) { for (StyleSpecification s : ss.getStyles().values()) { ComparableQName n = s.getName(); elt.setAttributeNS(n.getNamespaceURI(), n.getLocalPart(), s.getValue()); } elt.setAttributeNS(XML.xmlNamespace, "id", id); } }
public StyleSpecification get(QName qn) { return this.styles.get(qn instanceof ComparableQName ? qn : new ComparableQName(qn)); }
public static final boolean isFrameRateDefaulted(Object content) { return isParameterDefaulted(content, new ComparableQName(frameRateAttributeName)); }
public static final Set<ComparableQName> parseNames(String value) { Set<ComparableQName> names = new java.util.TreeSet<ComparableQName>(); if ((value != null) && (value.length() > 0)) { for (String n : value.split("[ \t]+")) { Matcher m = qnamePattern.matcher(n); if (m.matches()) { assert m.groupCount() == 2; String ns = m.group(1); String ln = m.group(2); names.add(new ComparableQName(ns, ln)); } } } return names; }
public static final boolean isTickRateDefaulted(Object content) { return isParameterDefaulted(content, new ComparableQName(tickRateAttributeName)); }
private static StyleSet getInlineStyles(Element e, int[] indices) { StyleSet styles = new StyleSet(generateStyleSetIndex(indices)); NamedNodeMap attrs = e.getAttributes(); for (int i = 0, n = attrs.getLength(); i < n; ++i) { Node node = attrs.item(i); if (node instanceof Attr) { Attr a = (Attr) node; String ns = a.getNamespaceURI(); if ((ns != null) && ns.equals(NAMESPACE_TT_STYLE)) { styles.merge(new StyleSpecification(new ComparableQName(a.getNamespaceURI(), a.getLocalName()), a.getValue())); } } } return styles; }
private static StyleSet getInlineStyles(Element elt, TransformerContext context) { StyleSet styles = new StyleSet(); NamedNodeMap attrs = elt.getAttributes(); for (int i = 0, n = attrs.getLength(); i < n; ++i) { Node node = attrs.item(i); if (node instanceof Attr) { Attr a = (Attr) node; String nsUri = a.getNamespaceURI(); if (nsUri != null) { QName styleName = new ComparableQName(a.getNamespaceURI(), a.getLocalName()); if (isDefinedStyle(styleName, context)) styles.merge(new StyleSpecification(styleName, a.getValue())); } } } return styles; }
private static StyleSpecification getInitialStyle(QName eltName, QName styleName, TransformerContext context, StyleSet overrides) { String value = context.getModel().getInitialStyleValue(eltName, styleName); if (value != null) { if (overrides != null) { StyleSpecification override = overrides.get(styleName); if (override != null) value = override.getValue(); } return new StyleSpecification(new ComparableQName(styleName), value); } else return null; }