本文整理了Java中net.htmlparser.jericho.Element.getStartTag()
方法的一些代码示例,展示了Element.getStartTag()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getStartTag()
方法的具体详情如下:
包路径:net.htmlparser.jericho.Element
类名称:Element
方法名:getStartTag
[英]Returns the start tag of the element.
[中]返回元素的开始标记。
代码示例来源:origin: net.htmlparser.jericho/jericho-html
/**
* 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();
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
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);
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
/**
* 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);
}
代码示例来源:origin: VueGWT/vue-gwt
/**
* 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);
}
代码示例来源:origin: VueGWT/vue-gwt
private Optional<Map<String, Class<?>>> getPropertiesForDOMElement(Element element) {
return DOMElementsUtil
.getTypeForElementTag(element.getStartTag().getName())
.map(DOMElementsUtil::getElementProperties);
}
代码示例来源:origin: cflint/CFLint
@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);
}
}
}
}
代码示例来源:origin: cflint/CFLint
@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);
}
}
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
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;
}
代码示例来源:origin: cflint/CFLint
@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);
}
}
}
代码示例来源:origin: cflint/CFLint
@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);
}
}
}
代码示例来源:origin: cflint/CFLint
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;
}
}
代码示例来源:origin: cflint/CFLint
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;
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
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());
}
代码示例来源:origin: wala/WALA
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;
}
代码示例来源:origin: com.ibm.wala/com.ibm.wala.cast.js
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;
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
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
}
代码示例来源:origin: konsoletyper/teavm-flavour
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;
}
代码示例来源:origin: VueGWT/vue-gwt
/**
* 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);
}
代码示例来源:origin: com.github.cfparser/cfml.parsing
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());
}
代码示例来源:origin: com.github.cfparser/cfml.parsing
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());
}
内容来源于网络,如有侵权,请联系作者删除!