本文整理了Java中net.htmlparser.jericho.Element.getAttributes()
方法的一些代码示例,展示了Element.getAttributes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getAttributes()
方法的具体详情如下:
包路径:net.htmlparser.jericho.Element
类名称:Element
方法名:getAttributes
[英]Returns the attributes specified in this element's start tag.
This is equivalent to #getStartTag().
StartTag#getAttributes().
[中]返回此元素的开始标记中指定的属性。
这相当于#getStartTag().
StartTag#getAttributes()。
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public String getAttributeValue(final String attributeName) {
if (attributesMap!=null)
return attributesMap.get(attributeName);
else
return element.getAttributes().getValue(attributeName);
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public Map<String,String> getAttributesMap() {
if (attributesMap==null) attributesMap=element.getAttributes().getMap(true);
return attributesMap;
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public boolean getBooleanAttribute(final String attributeName) {
if (attributesMap!=null)
return attributesMap.containsKey(attributeName);
else
return element.getAttributes().get(attributeName)!=null;
}
代码示例来源:origin: VueGWT/vue-gwt
private static boolean isScopedStyleElement(Element element) {
return element != null && "style".equalsIgnoreCase(element.getName())
&& element.getAttributes() != null && element.getAttributes().get("scoped") != null;
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public ElementContainer(final Element element, final boolean loadPredefinedValue) {
this.element=element;
predefinedValue=loadPredefinedValue ? element.getAttributes().getValue(Attribute.VALUE) : null;
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public void replaceAttributesInOutputDocumentIfModified(final OutputDocument outputDocument) {
if (attributesMap!=null) outputDocument.replace(element.getAttributes(),attributesMap);
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
private FormControl(final Element element, final FormControlType formControlType, final boolean loadPredefinedValue) {
super(element.source,element.begin,element.end);
elementContainer=new ElementContainer(element,loadPredefinedValue);
this.formControlType=formControlType;
name=element.getAttributes().getValue(Attribute.NAME);
verifyName();
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
final String name = element.getName();
final int line = element.getSource().getRow(element.getBegin());
int offset = element.getBegin();
if (name != null && name.trim().length() > 0 && context.isInFunction()) {
if (checkNames.contains(name.toLowerCase())) {
offset = element.getAttributes().get(CF.NAME) != null ? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : offset;
assertVariable(element, context, bugs, element.getAttributeValue(CF.NAME), line, offset);
}
if (checkElementAttributes.containsKey(name.toLowerCase())) {
for (final String attrName : checkElementAttributes.get(name.toLowerCase())) {
offset = element.getAttributes().get(attrName) != null
? element.getAttributes().get(attrName).getValueSegment().getBegin()
: offset;
assertVariable(element, context, bugs, element.getAttributeValue(attrName), line, offset);
}
}
}
}
代码示例来源:origin: net.htmlparser.jericho/jericho-html
public SelectFormControl(final Element element) {
super(element,element.getAttributes().get(Attribute.MULTIPLE)!=null ? FormControlType.SELECT_MULTIPLE : FormControlType.SELECT_SINGLE,false);
final List<Element> optionElements=element.getAllElements(HTMLElementName.OPTION);
optionElementContainers=new ElementContainer[optionElements.size()];
int x=0;
for (Element optionElement : optionElements) {
final ElementContainer optionElementContainer=new ElementContainer(optionElement,true);
if (optionElementContainer.predefinedValue==null)
// use the content of the element if it has no value attribute
optionElementContainer.predefinedValue=CharacterReference.decodeCollapseWhiteSpace(optionElementContainer.element.getContent());
optionElementContainers[x++]=optionElementContainer;
}
}
public String getPredefinedValue() {
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
final String name = element.getName();
final int line = element.getSource().getRow(element.getBegin());
int offset = element.getBegin();
if (name != null && name.trim().length() > 0 && context.isInFunction()) {
if (checkNames.contains(name.toLowerCase())) {
offset = element.getAttributes().get(CF.NAME) != null ? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : offset;
assertVariable(element, context, bugs, element.getAttributeValue(CF.NAME), line, offset);
}
if (checkElementAttributes.containsKey(name.toLowerCase())) {
for (final String attrName : checkElementAttributes.get(name.toLowerCase())) {
offset = element.getAttributes().get(attrName) != null
? element.getAttributes().get(attrName).getValueSegment().getBegin()
: offset;
assertVariable(element, context, bugs, element.getAttributeValue(attrName), line, offset);
}
}
}
}
代码示例来源: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: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final String name = element.getAttributeValue(CF.NAME) != null
? element.getAttributeValue(CF.NAME) : "";
ArgInfo argInfo = new ArgInfo();
argInfo.casedName=name;
argInfo.argumentLineNo=context.startLine();
argInfo.argumentOffset=element.getAttributeValue(CF.NAME) != null
? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : element.getBegin();
argInfo.type=element.getAttributeValue(CF.TYPE);
currentArgs.put(name.toLowerCase(), argInfo);
final String code = element.getParentElement().toString();
if (isUsed(code, name.toLowerCase())) {
argInfo.used=true;
}
}
}
代码示例来源:origin: cflint/CFLint
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final String name = element.getAttributeValue(CF.NAME) != null
? element.getAttributeValue(CF.NAME) : "";
ArgInfo argInfo = new ArgInfo();
argInfo.casedName=name;
argInfo.argumentLineNo=context.startLine();
argInfo.argumentOffset=element.getAttributeValue(CF.NAME) != null
? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : element.getBegin();
argInfo.type=element.getAttributeValue(CF.TYPE);
currentArgs.put(name.toLowerCase(), argInfo);
final String code = element.getParentElement().toString();
if (isUsed(code, name.toLowerCase())) {
argInfo.used=true;
}
}
}
代码示例来源:origin: cflint/CFLint
/**
* Parse a CF argument tag to see if any of the arguments names are invalid.
*/
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final int lineNo = context.startLine();
int offset = context.offset();
final String name = element.getAttributeValue(CF.NAME);
if (name != null && name.length() > 0) {
offset = element.getAttributes().get(CF.NAME).getValueSegment().getBegin();
checkNameForBugs(context, name, context.getFilename(), context.getFunctionName(), lineNo, offset, bugs);
} else {
context.addMessage("ARGUMENT_MISSING_NAME", null, this, lineNo, offset);
}
}
}
代码示例来源:origin: cflint/CFLint
/**
* Parse a CF argument tag to see if any of the arguments names are invalid.
*/
@Override
public void element(final Element element, final Context context, final BugList bugs) {
if (element.getName().equals(CF.CFARGUMENT)) {
final int lineNo = context.startLine();
int offset = context.offset();
final String name = element.getAttributeValue(CF.NAME);
if (name != null && name.length() > 0) {
offset = element.getAttributes().get(CF.NAME).getValueSegment().getBegin();
checkNameForBugs(context, name, context.getFilename(), context.getFunctionName(), lineNo, offset, bugs);
} else {
context.addMessage("ARGUMENT_MISSING_NAME", null, this, lineNo, offset);
}
}
}
代码示例来源:origin: cflint/CFLint
private void checkCFLoopName(final Element element, final Context context, final BugList bugs, final int begLine, int offset) {
if (element.getAttributeValue(CF.INDEX) != null || element.getAttributeValue(CF.ITEM) != null) {
String varName = "";
final String index = element.getAttributeValue(CF.INDEX);
final String item = element.getAttributeValue(CF.ITEM);
if (index != null) {
varName = index;
offset = element.getAttributes().get(CF.INDEX).getValueSegment().getBegin();
}
else if (item != null) {
varName = item;
offset = element.getAttributes().get(CF.ITEM).getValueSegment().getBegin();
}
checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine,
offset, bugs,null);
}
}
代码示例来源:origin: cflint/CFLint
private void checkCFLoopName(final Element element, final Context context, final BugList bugs, final int begLine, int offset) {
if (element.getAttributeValue(CF.INDEX) != null || element.getAttributeValue(CF.ITEM) != null) {
String varName = "";
final String index = element.getAttributeValue(CF.INDEX);
final String item = element.getAttributeValue(CF.ITEM);
if (index != null) {
varName = index;
offset = element.getAttributes().get(CF.INDEX).getValueSegment().getBegin();
}
else if (item != null) {
varName = item;
offset = element.getAttributes().get(CF.ITEM).getValueSegment().getBegin();
}
checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine,
offset, bugs,null);
}
}
代码示例来源:origin: cflint/CFLint
private void checkCFName(final Element element, final Context context, final BugList bugs, final int begLine, int offset, final String name) {
if (element.getAttributeValue(name) != null) {
final Attribute attribute = element.getAttributes().get(name);
String varName;
if (attribute != null) {
varName = attribute.getValue();
offset = attribute.getValueSegment().getBegin();
} else {
varName = "";
}
checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine, offset, bugs,null);
}
}
代码示例来源:origin: cflint/CFLint
private void checkCFName(final Element element, final Context context, final BugList bugs, final int begLine, int offset, final String name) {
if (element.getAttributeValue(name) != null) {
final Attribute attribute = element.getAttributes().get(name);
String varName;
if (attribute != null) {
varName = attribute.getValue();
offset = attribute.getValueSegment().getBegin();
} else {
varName = "";
}
checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine, offset, bugs,null);
}
}
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!