List of usage examples for org.xml.sax.helpers AttributesImpl AttributesImpl
public AttributesImpl(Attributes atts)
From source file:net.sourceforge.fenixedu.utilTests.ParseMetadata.java
@Override public void startElement(String uri, String localName, String qName, Attributes attributes) { current = new Element(uri, localName, qName, new AttributesImpl(attributes)); vector.addElement(current);/* w w w. j a va 2 s .c o m*/ text = new String(); }
From source file:com.adobe.acs.commons.rewriter.impl.ResourceResolverMapTransformerFactory.java
protected Attributes rebuildAttributes(final SlingHttpServletRequest slingRequest, final String elementName, final Attributes attrs) { if (slingRequest == null || !attributes.containsKey(elementName)) { // element is not defined as a candidate to rewrite return attrs; }/* www .j a va 2 s . c om*/ final String[] modifiableAttributes = attributes.get(elementName); // clone the attributes final AttributesImpl newAttrs = new AttributesImpl(attrs); final int len = newAttrs.getLength(); for (int i = 0; i < len; i++) { final String attrName = newAttrs.getLocalName(i); if (ArrayUtils.contains(modifiableAttributes, attrName)) { final String attrValue = newAttrs.getValue(i); if (StringUtils.startsWith(attrValue, "/") && !StringUtils.startsWith(attrValue, "//")) { // Only map absolute paths (starting w /), avoid relative-scheme URLs starting w // newAttrs.setValue(i, slingRequest.getResourceResolver().map(slingRequest, attrValue)); } } } return newAttrs; }
From source file:com.quinsoft.zeidon.standardoe.ActivateOisFromXmlStream.java
private void createEntity(String entityName, Attributes attributes) { currentEntityDef = lodDef.getEntityDef(entityName); currentEntityStack.push(currentEntityDef); EntityCursorImpl cursor = view.cursor(currentEntityDef); cursor.createEntity(CursorPosition.LAST, CREATE_FLAGS); // If we're setting incremental flags, save them for later. Create // a copy of the AttributesImpl because the original gets reused. if (incremental) entityAttributes.push(new AttributesImpl(attributes)); }
From source file:com.adobe.acs.commons.rewriter.impl.StaticReferenceRewriteTransformerFactory.java
@SuppressWarnings("squid:S3776") private Attributes rebuildAttributes(String elementName, Attributes attrs, String[] modifyableAttributes) { // clone the attributes final AttributesImpl newAttrs = new AttributesImpl(attrs); for (int i = 0; i < newAttrs.getLength(); i++) { final String attrName = newAttrs.getLocalName(i); if (ArrayUtils.contains(modifyableAttributes, attrName)) { final String attrValue = newAttrs.getValue(i); String key = elementName + ":" + attrName; if (matchingPatterns.containsKey(key)) { // Find value based on matching pattern Pattern matchingPattern = matchingPatterns.get(key); try { newAttrs.setValue(i, handleMatchingPatternAttribute(matchingPattern, attrValue)); } catch (Exception e) { log.error("Could not perform replacement based on matching pattern", e); }//w ww . j a va2 s . c o m } else { for (String prefix : prefixes) { if (attrValue.startsWith(prefix)) { newAttrs.setValue(i, prependHostName(attrValue)); } } } } } return newAttrs; }
From source file:com.adobe.acs.commons.rewriter.impl.VersionedClientlibsTransformerFactory.java
private Attributes versionClientLibs(final String elementName, final Attributes attrs, final SlingHttpServletRequest request) { if (SaxElementUtils.isCss(elementName, attrs)) { return this.rebuildAttributes(new AttributesImpl(attrs), attrs.getIndex("", ATTR_CSS_PATH), attrs.getValue("", ATTR_CSS_PATH), LibraryType.CSS, request); } else if (SaxElementUtils.isJavaScript(elementName, attrs)) { return this.rebuildAttributes(new AttributesImpl(attrs), attrs.getIndex("", ATTR_JS_PATH), attrs.getValue("", ATTR_JS_PATH), LibraryType.JS, request); } else {//from w ww . j a v a2 s .c om return attrs; } }
From source file:com.icesoft.faces.webapp.parser.ComponentRuleSet.java
/** * Create clone of attributes./*from w ww. j ava 2 s . com*/ * * @param attributes Attributes to clone. * @return Cloned attributes. */ private Attributes clone(Attributes attributes) { Attributes clone = new AttributesImpl(attributes); for (int i = 0; i < clone.getLength(); i++) { String name = attributes.getQName(i); String value = attributes.getValue(name); ((AttributesImpl) clone).setLocalName(i, name); ((AttributesImpl) clone).setValue(i, value); } return clone; }
From source file:com.icesoft.faces.webapp.parser.ComponentRuleSet.java
/** * Begin processing for the rule. Saves attributes, saves tag name, deals * with parent's preceeding body text, and wires up the tag processing * tree.//from w w w . j ava 2s . co m * * @param attributes Attributes for the tag. * @throws Exception No exception is thrown. */ public void begin(Attributes attributes) throws Exception { // Get all the important bits off the digester stack; TagWire wire = (TagWire) digester.peek(); XhtmlTag child = (XhtmlTag) digester.peek(1); TagWire parentWire = (TagWire) digester.peek(2); Tag parent = (Tag) digester.peek(3); // Save attributes; child.setAttributes((Attributes) (new AttributesImpl(attributes))); // Save the tag; child.setTagName(new String(digester.getCurrentElementName())); // Deal with preceeding body text; dealWithPreceedingBodyText(parent, parentWire); // Wire up the tree; wireUpTheTag((Tag) child, parent, wire, parentWire); }
From source file:ca.sqlpower.wabit.dao.WorkspaceSAXHandler.java
@Override public void startElement(final String uri, final String localName, final String name, final Attributes attr) throws SAXException { if (isCancelled()) { throw new CancellationException(); }//from w w w .ja v a 2 s . c om byteStream = new ByteArrayOutputStream(); final Attributes attributes = new AttributesImpl(attr); Runnable runner = new Runnable() { public void run() { try { context.startLoading(); startElementImpl(uri, localName, name, attributes); } catch (SAXException e) { setCancelled(true); throw new RuntimeException(e); } finally { context.endLoading(); } } }; session.runInForeground(runner); }
From source file:com.icesoft.faces.webapp.parser.ComponentRuleSet.java
private Attributes clone(Attributes attributes) { Attributes clone = new AttributesImpl(attributes); for (int i = 0; i < clone.getLength(); i++) { String name = attributes.getQName(i); String value = attributes.getValue(name); ((AttributesImpl) clone).setLocalName(i, name); ((AttributesImpl) clone).setValue(i, value); }// w w w .java 2s .c o m return clone; }
From source file:com.netspective.axiom.schema.column.BasicColumn.java
public void addSchemaRecordEditorDialogTemplates(TemplateElement dialogTemplate, Map jexlVars) { jexlVars.put("column", this); ForeignKey fKey = getForeignKey();/*from w ww . j a v a 2 s . co m*/ if (fKey != null && fKey.getReferencedColumns().getFirst().getTable() instanceof EnumerationTable) { addEnumerationSchemaRecordEditorDialogTemplates(dialogTemplate, jexlVars); return; } TemplateProducer columnPresentationTemplates = getPresentation(); if (columnPresentationTemplates.getInstances().size() > 0) { // get only the last template because if there was inheritace of a data-type we want the "final" one Template columnPresentationTemplate = (Template) columnPresentationTemplates.getInstances() .get(columnPresentationTemplates.getInstances().size() - 1); List copyColumnPresTmplChildren = columnPresentationTemplate.getChildren(); for (int i = 0; i < copyColumnPresTmplChildren.size(); i++) { TemplateNode colTmplChildNode = (TemplateNode) copyColumnPresTmplChildren.get(i); if (colTmplChildNode instanceof TemplateElement) { TemplateElement elem = dialogTemplate.addCopyOfChildAndReplaceExpressions( (TemplateElement) colTmplChildNode, jexlVars, true); if (elem.getElementName().equals("field")) { boolean changedAttrs = false; AttributesImpl attrs = new AttributesImpl(elem.getAttributes()); if (isPrimaryKey() && (attrs.getIndex("primary-key") == -1 && attrs.getIndex("primarykey") == -1 && attrs.getIndex("primary-key-generated") == -1 && attrs.getIndex("primarykeygenerated") == -1)) { if (this instanceof GeneratedValueColumn) attrs.addAttribute(null, null, "primary-key-generated", "CDATA", "yes"); else attrs.addAttribute(null, null, "primary-key", "CDATA", "yes"); if (attrs.getIndex("required") == -1) // unless required is being overidden, make the primary key field required attrs.addAttribute(null, null, "required", "CDATA", "yes"); changedAttrs = true; } if (isRequiredByApp() && attrs.getIndex("required") == -1) { attrs.addAttribute(null, null, "required", "CDATA", "yes"); changedAttrs = true; } if (changedAttrs) elem.setAttributes(attrs); } } else if (colTmplChildNode instanceof TemplateText) dialogTemplate.addChild( new TemplateText(dialogTemplate, ((TemplateText) colTmplChildNode).getText())); else throw new RuntimeException("This should never happen."); } } }