/** * Returns the attributes specified in this element's start tag. * <p> * This is equivalent to {@link #getStartTag()}<code>.</code>{@link StartTag#getAttributes() getAttributes()}. * * @return the attributes specified in this element's start tag. * @see StartTag#getAttributes() */ public Attributes getAttributes() { return getStartTag().getAttributes(); }
public void process(Processor x, Element element) throws IOException { if (!x.includeAlternateText) return; String text=x.renderer.renderAlternateText(element.getStartTag()); if (text==null) return; x.appendText(text); } }
/** * Returns the {@linkplain CharacterReference#decode(CharSequence) decoded} value of the attribute with the specified name (case insensitive). * <p> * Returns <code>null</code> if the {@linkplain #getStartTag() start tag of this element} does not * {@linkplain StartTagType#hasAttributes() have attributes}, * no attribute with the specified name exists or the attribute {@linkplain Attribute#hasValue() has no value}. * <p> * This is equivalent to {@link #getStartTag()}<code>.</code>{@link StartTag#getAttributeValue(String) getAttributeValue(attributeName)}. * * @param attributeName the name of the attribute to get. * @return the {@linkplain CharacterReference#decode(CharSequence) decoded} value of the attribute with the specified name, or <code>null</code> if the attribute does not exist or {@linkplain Attribute#hasValue() has no value}. */ public String getAttributeValue(final String attributeName) { return getStartTag().getAttributeValue(attributeName); }
/** * Find the corresponding TypeMirror from Elemental2 for a given DOM Element * * @param element The element we want the TypeMirror of * @return The type mirror */ private TypeMirror getTypeFromDOMElement(Element element) { return DOMElementsUtil .getTypeForElementTag(element.getStartTag().getName()) .map(Class::getCanonicalName) .map(elements::getTypeElement) .map(TypeElement::asType) .orElse(null); }
private Optional<Map<String, Class<?>>> getPropertiesForDOMElement(Element element) { return DOMElementsUtil .getTypeForElementTag(element.getStartTag().getName()) .map(DOMElementsUtil::getElementProperties); }
@Override public void element(final Element element, final Context context, final BugList bugs) { if ("script".equals(element.getName())) { final String src = element.getStartTag().toString(); if (!src.matches(".*src=.*")) { context.addMessage("AVOID_USING_INLINE_JS", null); } } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { if ("script".equals(element.getName())) { final String src = element.getStartTag().toString(); if (!src.matches(".*src=.*")) { context.addMessage("AVOID_USING_INLINE_JS", null); } } } }
private static ElementHandler getElementHandler(final Element element) { if (element.getStartTag().getStartTagType().isServerTag()) return RemoveElementHandler.INSTANCE; // hard-coded configuration does not include server tags in child element hierarchy, so this is normally not executed. ElementHandler elementHandler=ELEMENT_HANDLERS.get(element.getName()); return (elementHandler!=null) ? elementHandler : StandardInlineElementHandler.INSTANCE; }
@Override public void element(final Element element, final Context context, final BugList bugs) { if (element.getName().equals(CF.CFSET)) { final String content = element.getStartTag().getTagContent().toString(); if (content.toLowerCase().contains("arraynew(1)")) { context.addMessage("AVOID_USING_ARRAYNEW", null); } } }
@Override public void element(final Element element, final Context context, final BugList bugs) { if (element.getName().equals(CF.CFSET)) { final String content = element.getStartTag().getTagContent().toString(); if (content.toLowerCase().contains("arraynew(1)")) { context.addMessage("AVOID_USING_ARRAYNEW", null); } } }
public int offset() { if (element != null) { if (element.getName().equalsIgnoreCase(CF.CFSCRIPT)) { return element.getStartTag().getEnd(); } else if (element.getName().equalsIgnoreCase(CF.CFSET)) { return element.getStartTag().getTagContent().getBegin() + 1; } return element.getBegin(); } else { return 0; } }
public int offset() { if (element != null) { if (element.getName().equalsIgnoreCase(CF.CFSCRIPT)) { return element.getStartTag().getEnd(); } else if (element.getName().equalsIgnoreCase(CF.CFSET)) { return element.getStartTag().getTagContent().getBegin() + 1; } return element.getBegin(); } else { return 0; } }
private void appendElementContent(final Element element) throws IOException { final int contentEnd=element.getContentEnd(); if (element.isEmpty() || renderedIndex>=contentEnd) return; final int contentBegin=element.getStartTag().end; appendSegmentProcessingChildElements(Math.max(renderedIndex,contentBegin),contentEnd,element.getChildElements()); }
private Map<String, Pair<String, Position>> makeAllAttributes() { Map<String, Pair<String, Position>> result = HashMapFactory.make(); if (innerElement.getStartTag().getAttributes() != null) { for (Attribute a : innerElement.getStartTag().getAttributes()) { result.put( a.getName().toLowerCase(), Pair.make(a.getValue(), getPosition(a.getValueSegment()))); } } return result; }
private Map<String, Pair<String, Position>> makeAllAttributes() { Map<String, Pair<String, Position>> result = HashMapFactory.make(); if (innerElement.getStartTag().getAttributes() != null) { for (Attribute a : innerElement.getStartTag().getAttributes()) { result.put( a.getName().toLowerCase(), Pair.make(a.getValue(), getPosition(a.getValueSegment()))); } } return result; }
private boolean inlinable(final Element element) { // returns true if the specified element should be inlined final StartTagType startTagType=element.getStartTag().getStartTagType(); // if (startTagType==StartTagType.DOCTYPE_DECLARATION) return false; // this was removed because it caused an extra line break if the DOCTYPE is preceeded by a server tag if (startTagType!=StartTagType.NORMAL) return true; // element is a normal type final String elementName=element.getName(); if (elementName==HTMLElementName.SCRIPT) return !indentScriptElements; if (removeLineBreaks && !HTMLElements.getElementNames().contains(elementName)) return true; // inline non-HTML elements if removing line breaks if (!HTMLElements.getInlineLevelElementNames().contains(elementName)) return false; // element is inline type if (elementName==HTMLElementName.TEXTAREA) return false; // TEXTAREA is theoretically inlinable but we want to format its content in the same was as PRE, and this is easiest when the entire element is treated like a block PRE element. if (removeLineBreaks) return true; return containsOnlyInlineLevelChildElements(element); // only inline if it doesn't illegally contain non-inline elements }
private TemplateNode parseComponent(Element elem) { int prefixLength = elem.getName().indexOf(':'); String prefix = elem.getName().substring(0, prefixLength); String name = elem.getName().substring(prefixLength + 1); String fullName = prefix + ":" + name; ElementComponentMetadata componentMeta = resolveComponent(prefix, name); if (componentMeta == null) { error(elem.getStartTag().getNameSegment(), "Undefined component " + fullName); return null; } List<PostponedComponentParse> postponedList = new ArrayList<>(); TemplateNode node = parseComponent(componentMeta, prefix, name, elem, postponedList, new MapSubstitutions(new HashMap<>())); completeComponentParsing(postponedList, componentMeta, elem); position = elem.getEnd(); return node; }
/** * Return the {@link LocalComponent} definition for a given DOM {@link Element} * * @param element Current element being processed * @return An Optional {@link LocalComponent} */ private Optional<LocalComponent> getLocalComponentForElement(Element element) { String componentName = element.getAttributes().getValue("is"); if (componentName == null) { componentName = element.getStartTag().getName(); } return context.getLocalComponent(componentName); }
public ParserTag(StartTag tag) { setName(tag.getName()); setBegin(tag.getElement().getEnd()); setEnd(tag.getElement().getBegin()); setStartTagBegin(tag.getElement().getStartTag().getBegin()); setStartTagEnd(tag.getElement().getStartTag().getEnd()); if (tag.getElement().getEndTag() != null) { setEndTagBegin(tag.getElement().getEndTag().getBegin()); setEndTagEnd(tag.getElement().getEndTag().getEnd()); } else { setEndTagBegin(tag.getElement().getStartTag().getBegin()); setEndTagEnd(tag.getElement().getStartTag().getEnd()); } setAttributes(tag.getAttributes()); }
public ParserTag(net.htmlparser.jericho.Tag tag) { setName(tag.getName()); setBegin(tag.getElement().getEnd()); setEnd(tag.getElement().getBegin()); setStartTagBegin(tag.getElement().getStartTag().getBegin()); setStartTagEnd(tag.getElement().getStartTag().getEnd()); if (tag.getElement().getEndTag() != null) { setEndTagBegin(tag.getElement().getEndTag().getBegin()); setEndTagEnd(tag.getElement().getEndTag().getEnd()); } else { setEndTagBegin(tag.getElement().getStartTag().getBegin()); setEndTagEnd(tag.getElement().getStartTag().getEnd()); } setAttributes(tag.getElement().getAttributes()); }