/** * Get the DTD elements for specific device context. * @param string DTD spec string e.g. "elcspec:empty" * @return List of element names. */ private String[] getDTDElements(String string) { String tmpString = string; if(tmpString.startsWith(ELCSPEC_PREFIX)) { tmpString = tmpString.substring(ELCSPEC_PREFIX.length()); if(tmpString.equals("empty")) { return dtd.getEmptyElements(); } else if(tmpString.equals("not-empty")) { return dtd.getNonEmptyElements(); } else if(tmpString.equals("any")) { return dtd.getAnyElements(); } else if(tmpString.equals("not-any")) { return dtd.getNonAnyElements(); } else if(tmpString.equals("mixed")) { return dtd.getMixedElements(); } else if(tmpString.equals("not-mixed")) { return dtd.getNonMixedElements(); } else if(tmpString.equals("pcdata")) { return dtd.getPCDataElements(); } else if(tmpString.equals("not-pcdata")) { return dtd.getNonPCDataElements(); } } throw new IllegalStateException("Unsupported DTD spec definition [" + string + "]"); }
/** * Get the child elements for the named element. * <p/> * PCData is returned as a "*" list entry. * @param elementName Element name. * @return List of allowed element names ({@link String}s). */ @SuppressWarnings({ "WeakerAccess", "unchecked" }) public List getChildElements(String elementName) { Vector childElements = (Vector)elementElements.get(elementName); if(childElements == null) { DTDElement element = getElement(elementName); if(element != null) { childElements = new Vector(); elementElements.put(elementName, childElements); if(element.content instanceof DTDContainer) { DTDContainer container = (DTDContainer)element.content; Vector itemsVec = container.getItemsVec(); for(int i = 0; i < itemsVec.size(); i++) { Object item = itemsVec.elementAt(i); if(item instanceof DTDName) { childElements.add(((DTDName)item).getValue()); } } } } } return childElements; }
DTDElement element = getElement(elementName);
/** * Get the child elements for the named element. * <p/> * PCData is returned as a "*" list entry. * @param elementName Element name. * @return List of allowed element names ({@link String}s). */ @SuppressWarnings({ "WeakerAccess", "unchecked" }) public List getChildElements(String elementName) { Vector childElements = (Vector)elementElements.get(elementName); if(childElements == null) { DTDElement element = getElement(elementName); if(element != null) { childElements = new Vector(); elementElements.put(elementName, childElements); if(element.content instanceof DTDContainer) { DTDContainer container = (DTDContainer)element.content; Vector itemsVec = container.getItemsVec(); for(int i = 0; i < itemsVec.size(); i++) { Object item = itemsVec.elementAt(i); if(item instanceof DTDName) { childElements.add(((DTDName)item).getValue()); } } } } } return childElements; }
/** * Get the child elements for the named element. * <p/> * PCData is returned as a "*" list entry. * @param elementName Element name. * @return List of allowed element names ({@link String}s). */ @SuppressWarnings({ "WeakerAccess", "unchecked" }) public List getChildElements(String elementName) { Vector childElements = (Vector)elementElements.get(elementName); if(childElements == null) { DTDElement element = getElement(elementName); if(element != null) { childElements = new Vector(); elementElements.put(elementName, childElements); if(element.content instanceof DTDContainer) { DTDContainer container = (DTDContainer)element.content; Vector itemsVec = container.getItemsVec(); for(int i = 0; i < itemsVec.size(); i++) { Object item = itemsVec.elementAt(i); if(item instanceof DTDName) { childElements.add(((DTDName)item).getValue()); } } } } } return childElements; }
/** * Get the DTD elements for specific device context. * @param string DTD spec string e.g. "elcspec:empty" * @return List of element names. */ private String[] getDTDElements(String string) { String tmpString = string; if(tmpString.startsWith(ELCSPEC_PREFIX)) { tmpString = tmpString.substring(ELCSPEC_PREFIX.length()); if(tmpString.equals("empty")) { return dtd.getEmptyElements(); } else if(tmpString.equals("not-empty")) { return dtd.getNonEmptyElements(); } else if(tmpString.equals("any")) { return dtd.getAnyElements(); } else if(tmpString.equals("not-any")) { return dtd.getNonAnyElements(); } else if(tmpString.equals("mixed")) { return dtd.getMixedElements(); } else if(tmpString.equals("not-mixed")) { return dtd.getNonMixedElements(); } else if(tmpString.equals("pcdata")) { return dtd.getPCDataElements(); } else if(tmpString.equals("not-pcdata")) { return dtd.getNonPCDataElements(); } } throw new IllegalStateException("Unsupported DTD spec definition [" + string + "]"); }
/** * Get the DTD elements for specific device context. * @param string DTD spec string e.g. "elcspec:empty" * @return List of element names. */ private String[] getDTDElements(String string) { String tmpString = string; if(tmpString.startsWith(ELCSPEC_PREFIX)) { tmpString = tmpString.substring(ELCSPEC_PREFIX.length()); if(tmpString.equals("empty")) { return dtd.getEmptyElements(); } else if(tmpString.equals("not-empty")) { return dtd.getNonEmptyElements(); } else if(tmpString.equals("any")) { return dtd.getAnyElements(); } else if(tmpString.equals("not-any")) { return dtd.getNonAnyElements(); } else if(tmpString.equals("mixed")) { return dtd.getMixedElements(); } else if(tmpString.equals("not-mixed")) { return dtd.getNonMixedElements(); } else if(tmpString.equals("pcdata")) { return dtd.getPCDataElements(); } else if(tmpString.equals("not-pcdata")) { return dtd.getNonPCDataElements(); } } throw new IllegalStateException("Unsupported DTD spec definition [" + string + "]"); }
/** * Get the defined element attributes for the named element. * @param elementName The element name. * @return The list of attribute names ({@link String}s) for the named element. * @throws ElementNotDefined Element not defined. Calls shouldn't be made to this * function for undefined elements. */ @SuppressWarnings({ "WeakerAccess", "unchecked" }) public List getElementAttributes(String elementName) throws ElementNotDefined { Vector attributes = (Vector)elementAttributes.get(elementName); if(attributes == null) { DTDElement element = getElement(elementName); if(element != null) { attributes = new Vector(); elementAttributes.put(elementName, attributes); attributes.addAll(element.attributes.keySet()); } else { throw new ElementNotDefined("Element [" + elementName + "] not defined in DTD."); } } return attributes; }
/** * Get the defined element attributes for the named element. * @param elementName The element name. * @return The list of attribute names ({@link String}s) for the named element. * @throws ElementNotDefined Element not defined. Calls shouldn't be made to this * function for undefined elements. */ public List getElementAttributes(String elementName) throws ElementNotDefined { Vector attributes = (Vector)elementAttributes.get(elementName); if(attributes == null) { DTDElement element = getElement(elementName); if(element != null) { attributes = new Vector(); elementAttributes.put(elementName, attributes); attributes.addAll(element.attributes.keySet()); } else { throw new ElementNotDefined("Element [" + elementName + "] not defined in DTD."); } } return attributes; }
/** * Get the defined element attributes for the named element. * @param elementName The element name. * @return The list of attribute names ({@link String}s) for the named element. * @throws ElementNotDefined Element not defined. Calls shouldn't be made to this * function for undefined elements. */ @SuppressWarnings({ "WeakerAccess", "unchecked" }) public List getElementAttributes(String elementName) throws ElementNotDefined { Vector attributes = (Vector)elementAttributes.get(elementName); if(attributes == null) { DTDElement element = getElement(elementName); if(element != null) { attributes = new Vector(); elementAttributes.put(elementName, attributes); attributes.addAll(element.attributes.keySet()); } else { throw new ElementNotDefined("Element [" + elementName + "] not defined in DTD."); } } return attributes; }
/** * Get the DTD elements for specific device context. * @param string DTD spec string e.g. "elcspec:empty" * @return List of element names. */ private String[] getDTDElements(String string) { String tmpString = string; if(tmpString.startsWith(ELCSPEC_PREFIX)) { tmpString = tmpString.substring(ELCSPEC_PREFIX.length()); if(tmpString.equals("empty")) { return dtd.getEmptyElements(); } else if(tmpString.equals("not-empty")) { return dtd.getNonEmptyElements(); } else if(tmpString.equals("any")) { return dtd.getAnyElements(); } else if(tmpString.equals("not-any")) { return dtd.getNonAnyElements(); } else if(tmpString.equals("mixed")) { return dtd.getMixedElements(); } else if(tmpString.equals("not-mixed")) { return dtd.getNonMixedElements(); } else if(tmpString.equals("pcdata")) { return dtd.getPCDataElements(); } else if(tmpString.equals("not-pcdata")) { return dtd.getNonPCDataElements(); } } throw new IllegalStateException("Unsupported DTD spec definition [" + string + "]"); }
/** * Get the defined element attributes for the named element. * @param elementName The element name. * @return The list of attribute names ({@link String}s) for the named element. * @throws ElementNotDefined Element not defined. Calls shouldn't be made to this * function for undefined elements. */ @SuppressWarnings({ "WeakerAccess", "unchecked" }) public List getElementAttributes(String elementName) throws ElementNotDefined { Vector attributes = (Vector)elementAttributes.get(elementName); if(attributes == null) { DTDElement element = getElement(elementName); if(element != null) { attributes = new Vector(); elementAttributes.put(elementName, attributes); attributes.addAll(element.attributes.keySet()); } else { throw new ElementNotDefined("Element [" + elementName + "] not defined in DTD."); } } return attributes; }
/** * Get the list of DTD elements whose content spec is defined as being #PCDATA. * @return Array of elements names. */ public String[] getNonPCDataElements() { return getElements(DTDPCData.class, false); } }
/** * Get the list of DTD elements whose content spec is not defined as being MIXED. * @return Array of elements names. */ public String[] getNonMixedElements() { return getElements(DTDMixed.class, false); }
/** * Get the list of DTD elements whose content spec is not defined as being ANY. * @return Array of elements names. */ public String[] getNonAnyElements() { return getElements(DTDAny.class, false); }
private void initialiseEmptyElements() { DTDStore.DTDObjectContainer dtd = execContext.getDeliveryConfig().getDTD(); if(dtd != null) { String[] emptyEls = dtd.getEmptyElements(); if(emptyEls != null && emptyEls.length > 0) { for(int i = 0; i < emptyEls.length; i++) { emptyElements.add(emptyEls[i]); } } } }
/** * Get the list of DTD elements whose content spec is defined as being MIXED. * @return Array of elements names. */ public String[] getMixedElements() { return getElements(DTDMixed.class, true); }
/** * Get the list of DTD elements whose content spec is defined as being #PCDATA. * @return Array of elements names. */ public String[] getPCDataElements() { return getElements(DTDPCData.class, true); }
/** * Get the list of DTD elements whose content spec is defined as being ANY. * @return Array of elements names. */ public String[] getAnyElements() { return getElements(DTDAny.class, true); }
/** * Get the list of DTD elements whose content spec is defined as being MIXED. * @return Array of elements names. */ public String[] getMixedElements() { return getElements(DTDMixed.class, true); }