/** * Set attribute with given key, value pair where the value is quoted by quote. * @param key The name of the attribute. * @param value The value of the attribute. * @param quote The quote character to be used around value. * If zero, it is an unquoted value. */ public void setAttribute (String key, String value, char quote) { setAttribute (new Attribute (key, value, quote)); }
/** * Set attribute with given key, value pair where the value is quoted by quote. * @param key The name of the attribute. * @param value The value of the attribute. * @param quote The quote character to be used around value. * If zero, it is an unquoted value. */ public void setAttribute (String key, String value, char quote) { setAttribute (new Attribute (key, value, quote)); }
private static Vector cloneAttributes(Vector<Attribute> attributes) { Vector<Attribute> newAttributes = new Vector<>(attributes.size()); for (Attribute a : attributes) { newAttributes.add(new Attribute(a.getName(), a.getAssignment(), a.getValue(), a.getQuote())); } return newAttributes; }
/** * Adds a tag that will be preserved by <code>{@link #stripHtml(String)}</code>.<p> * * @param tagName the name of the tag to keep (case insensitive) * * @return true if the tagName was added correctly to the internal engine */ public boolean addPreserveTag(final String tagName) { Vector<Attribute> attributeList = new Vector<Attribute>(1); Attribute tagNameAttribute = new Attribute(); tagNameAttribute.setName(tagName.toLowerCase()); attributeList.add(tagNameAttribute); Tag keepTag = m_nodeFactory.createTagNode(null, 0, 0, attributeList); boolean result = m_nodeFactory.addTagPreserve(keepTag); return result; }
/** * Adds a tag that will be preserved by <code>{@link #stripHtml(String)}</code>.<p> * * @param tagName the name of the tag to keep (case insensitive) * * @return true if the tagName was added correctly to the internal engine */ public boolean addPreserveTag(final String tagName) { Vector attributeList = new Vector(1); Attribute tagNameAttribute = new Attribute(); tagNameAttribute.setName(tagName.toLowerCase()); attributeList.add(tagNameAttribute); Tag keepTag = m_nodeFactory.createTagNode(null, 0, 0, attributeList); boolean result = m_nodeFactory.addTagPreserve(keepTag); return result; }
private static Vector cloneAttributes(Vector<Attribute> attributes) { Vector<Attribute> newAttributes = new Vector<>(attributes.size()); for (Attribute a : attributes) { newAttributes.add(new Attribute(a.getName(), a.getAssignment(), a.getValue(), a.getQuote())); } return newAttributes; }
/** * Set the <code>HTTP-EQUIV</code> attribute. * @param httpEquiv The new value of the <code>HTTP-EQUIV</code> attribute. */ public void setHttpEquiv (String httpEquiv) { Attribute equiv; equiv = getAttributeEx ("HTTP-EQUIV"); if (null != equiv) equiv.setValue (httpEquiv); else getAttributesEx ().add (new Attribute ("HTTP-EQUIV", httpEquiv)); }
/** * Set the <code>CONTENT</code> attribute. * @param metaTagContents The new value of the <code>CONTENT</code> attribute. */ public void setMetaTagContents (String metaTagContents) { Attribute content; content = getAttributeEx ("CONTENT"); if (null != content) content.setValue (metaTagContents); else getAttributesEx ().add (new Attribute ("CONTENT", metaTagContents)); }
/** * Set the <code>NAME</code> attribute. * @param metaTagName The new value of the <code>NAME</code> attribute. */ public void setMetaTagName (String metaTagName) { Attribute name; name = getAttributeEx ("NAME"); if (null != name) name.setValue (metaTagName); else getAttributesEx ().add (new Attribute ("NAME", metaTagName)); }
/** * Set the <code>CONTENT</code> attribute. * @param metaTagContents The new value of the <code>CONTENT</code> attribute. */ public void setMetaTagContents (String metaTagContents) { Attribute content; content = getAttributeEx ("CONTENT"); if (null != content) content.setValue (metaTagContents); else getAttributesEx ().add (new Attribute ("CONTENT", metaTagContents)); }
/** * Set the <code>HTTP-EQUIV</code> attribute. * @param httpEquiv The new value of the <code>HTTP-EQUIV</code> attribute. */ public void setHttpEquiv (String httpEquiv) { Attribute equiv; equiv = getAttributeEx ("HTTP-EQUIV"); if (null != equiv) equiv.setValue (httpEquiv); else getAttributesEx ().add (new Attribute ("HTTP-EQUIV", httpEquiv)); }
/** * Set the <code>NAME</code> attribute. * @param metaTagName The new value of the <code>NAME</code> attribute. */ public void setMetaTagName (String metaTagName) { Attribute name; name = getAttributeEx ("NAME"); if (null != name) name.setValue (metaTagName); else getAttributesEx ().add (new Attribute ("NAME", metaTagName)); }
/** * Ensures that the given tag has the "alt" attribute set.<p> * * if not set, it will be set from the title of the given resource.<p> * * @param tag the tag to set the alt attribute for * @param internalUri the internal URI to get the title from */ protected void setAltAttributeFromTitle(Tag tag, String internalUri) { boolean hasAltAttrib = (tag.getAttribute("alt") != null); if (!hasAltAttrib) { String value = null; if ((internalUri != null) && (m_rootCms != null)) { // internal image: try to read the "alt" text from the "Title" property try { value = m_rootCms.readPropertyObject(internalUri, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue(); } catch (CmsException e) { // property can't be read, ignore } } // some editors add a "/" at the end of the tag, we must make sure to insert before that Vector attrs = tag.getAttributesEx(); // first element is always the tag name attrs.add(1, new Attribute(" ")); attrs.add(2, new Attribute("alt", value == null ? "" : value, '"')); } }
Attribute zeroth; attribute = new Attribute (name, null, (char)0); attributes = getAttributesEx (); if (null == attributes)
/** * Creates an end tag with the same name as the given tag. * @param tag The tag to end. * @param lexer The object containg the node factory. * @param page The page the tag is on (virtually). * @param position The offset into the page at which the tag is to * be anchored. * @return An end tag with the name '"/" + tag.getTagName()' and a start * and end position at the given position. The fact these positions are * equal may be used to distinguish it as a virtual tag later on. */ protected Tag createVirtualEndTag (Tag tag, Lexer lexer, Page page, int position) throws ParserException { Tag ret; String name; Vector attributes; name = "/" + tag.getRawTagName (); attributes = new Vector (); attributes.addElement (new Attribute (name, (String)null)); ret = lexer.getNodeFactory ().createTagNode ( page, position, position, attributes); return (ret); }
/** * Creates an end tag with the same name as the given tag. * @param tag The tag to end. * @param lexer The object containg the node factory. * @param page The page the tag is on (virtually). * @param position The offset into the page at which the tag is to * be anchored. * @return An end tag with the name '"/" + tag.getTagName()' and a start * and end position at the given position. The fact these positions are * equal may be used to distinguish it as a virtual tag later on. */ protected Tag createVirtualEndTag (Tag tag, Lexer lexer, Page page, int position) throws ParserException { Tag ret; String name; List attributes; name = "/" + tag.getRawTagName (); attributes = new ArrayList (); attributes.add (new Attribute (name, (String)null)); ret = lexer.getNodeFactory ().createTagNode ( page, position, position, attributes); return (ret); }
Attribute zeroth; attribute = new Attribute (name, null, (char)0); attributes = getAttributesEx (); if (null == attributes)
attribute = new Attribute ("/style", null); vector = new ArrayList (); vector.add (attribute);