net.htmlparser.jericho.Element.getAttributes()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(11.0k)|赞(0)|评价(0)|浏览(241)

本文整理了Java中net.htmlparser.jericho.Element.getAttributes()方法的一些代码示例,展示了Element.getAttributes()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getAttributes()方法的具体详情如下:
包路径:net.htmlparser.jericho.Element
类名称:Element
方法名:getAttributes

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

  1. public String getAttributeValue(final String attributeName) {
  2. if (attributesMap!=null)
  3. return attributesMap.get(attributeName);
  4. else
  5. return element.getAttributes().getValue(attributeName);
  6. }

代码示例来源:origin: net.htmlparser.jericho/jericho-html

  1. public Map<String,String> getAttributesMap() {
  2. if (attributesMap==null) attributesMap=element.getAttributes().getMap(true);
  3. return attributesMap;
  4. }

代码示例来源:origin: net.htmlparser.jericho/jericho-html

  1. public boolean getBooleanAttribute(final String attributeName) {
  2. if (attributesMap!=null)
  3. return attributesMap.containsKey(attributeName);
  4. else
  5. return element.getAttributes().get(attributeName)!=null;
  6. }

代码示例来源:origin: VueGWT/vue-gwt

  1. private static boolean isScopedStyleElement(Element element) {
  2. return element != null && "style".equalsIgnoreCase(element.getName())
  3. && element.getAttributes() != null && element.getAttributes().get("scoped") != null;
  4. }

代码示例来源:origin: net.htmlparser.jericho/jericho-html

  1. public ElementContainer(final Element element, final boolean loadPredefinedValue) {
  2. this.element=element;
  3. predefinedValue=loadPredefinedValue ? element.getAttributes().getValue(Attribute.VALUE) : null;
  4. }

代码示例来源:origin: net.htmlparser.jericho/jericho-html

  1. public void replaceAttributesInOutputDocumentIfModified(final OutputDocument outputDocument) {
  2. if (attributesMap!=null) outputDocument.replace(element.getAttributes(),attributesMap);
  3. }
  4. }

代码示例来源:origin: net.htmlparser.jericho/jericho-html

  1. private FormControl(final Element element, final FormControlType formControlType, final boolean loadPredefinedValue) {
  2. super(element.source,element.begin,element.end);
  3. elementContainer=new ElementContainer(element,loadPredefinedValue);
  4. this.formControlType=formControlType;
  5. name=element.getAttributes().getValue(Attribute.NAME);
  6. verifyName();
  7. }

代码示例来源:origin: cflint/CFLint

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. final String name = element.getName();
  4. final int line = element.getSource().getRow(element.getBegin());
  5. int offset = element.getBegin();
  6. if (name != null && name.trim().length() > 0 && context.isInFunction()) {
  7. if (checkNames.contains(name.toLowerCase())) {
  8. offset = element.getAttributes().get(CF.NAME) != null ? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : offset;
  9. assertVariable(element, context, bugs, element.getAttributeValue(CF.NAME), line, offset);
  10. }
  11. if (checkElementAttributes.containsKey(name.toLowerCase())) {
  12. for (final String attrName : checkElementAttributes.get(name.toLowerCase())) {
  13. offset = element.getAttributes().get(attrName) != null
  14. ? element.getAttributes().get(attrName).getValueSegment().getBegin()
  15. : offset;
  16. assertVariable(element, context, bugs, element.getAttributeValue(attrName), line, offset);
  17. }
  18. }
  19. }
  20. }

代码示例来源:origin: net.htmlparser.jericho/jericho-html

  1. public SelectFormControl(final Element element) {
  2. super(element,element.getAttributes().get(Attribute.MULTIPLE)!=null ? FormControlType.SELECT_MULTIPLE : FormControlType.SELECT_SINGLE,false);
  3. final List<Element> optionElements=element.getAllElements(HTMLElementName.OPTION);
  4. optionElementContainers=new ElementContainer[optionElements.size()];
  5. int x=0;
  6. for (Element optionElement : optionElements) {
  7. final ElementContainer optionElementContainer=new ElementContainer(optionElement,true);
  8. if (optionElementContainer.predefinedValue==null)
  9. // use the content of the element if it has no value attribute
  10. optionElementContainer.predefinedValue=CharacterReference.decodeCollapseWhiteSpace(optionElementContainer.element.getContent());
  11. optionElementContainers[x++]=optionElementContainer;
  12. }
  13. }
  14. public String getPredefinedValue() {

代码示例来源:origin: cflint/CFLint

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. final String name = element.getName();
  4. final int line = element.getSource().getRow(element.getBegin());
  5. int offset = element.getBegin();
  6. if (name != null && name.trim().length() > 0 && context.isInFunction()) {
  7. if (checkNames.contains(name.toLowerCase())) {
  8. offset = element.getAttributes().get(CF.NAME) != null ? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : offset;
  9. assertVariable(element, context, bugs, element.getAttributeValue(CF.NAME), line, offset);
  10. }
  11. if (checkElementAttributes.containsKey(name.toLowerCase())) {
  12. for (final String attrName : checkElementAttributes.get(name.toLowerCase())) {
  13. offset = element.getAttributes().get(attrName) != null
  14. ? element.getAttributes().get(attrName).getValueSegment().getBegin()
  15. : offset;
  16. assertVariable(element, context, bugs, element.getAttributeValue(attrName), line, offset);
  17. }
  18. }
  19. }
  20. }

代码示例来源:origin: VueGWT/vue-gwt

  1. /**
  2. * Return the {@link LocalComponent} definition for a given DOM {@link Element}
  3. *
  4. * @param element Current element being processed
  5. * @return An Optional {@link LocalComponent}
  6. */
  7. private Optional<LocalComponent> getLocalComponentForElement(Element element) {
  8. String componentName = element.getAttributes().getValue("is");
  9. if (componentName == null) {
  10. componentName = element.getStartTag().getName();
  11. }
  12. return context.getLocalComponent(componentName);
  13. }

代码示例来源:origin: cflint/CFLint

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (element.getName().equals(CF.CFARGUMENT)) {
  4. final String name = element.getAttributeValue(CF.NAME) != null
  5. ? element.getAttributeValue(CF.NAME) : "";
  6. ArgInfo argInfo = new ArgInfo();
  7. argInfo.casedName=name;
  8. argInfo.argumentLineNo=context.startLine();
  9. argInfo.argumentOffset=element.getAttributeValue(CF.NAME) != null
  10. ? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : element.getBegin();
  11. argInfo.type=element.getAttributeValue(CF.TYPE);
  12. currentArgs.put(name.toLowerCase(), argInfo);
  13. final String code = element.getParentElement().toString();
  14. if (isUsed(code, name.toLowerCase())) {
  15. argInfo.used=true;
  16. }
  17. }
  18. }

代码示例来源:origin: cflint/CFLint

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (element.getName().equals(CF.CFARGUMENT)) {
  4. final String name = element.getAttributeValue(CF.NAME) != null
  5. ? element.getAttributeValue(CF.NAME) : "";
  6. ArgInfo argInfo = new ArgInfo();
  7. argInfo.casedName=name;
  8. argInfo.argumentLineNo=context.startLine();
  9. argInfo.argumentOffset=element.getAttributeValue(CF.NAME) != null
  10. ? element.getAttributes().get(CF.NAME).getValueSegment().getBegin() : element.getBegin();
  11. argInfo.type=element.getAttributeValue(CF.TYPE);
  12. currentArgs.put(name.toLowerCase(), argInfo);
  13. final String code = element.getParentElement().toString();
  14. if (isUsed(code, name.toLowerCase())) {
  15. argInfo.used=true;
  16. }
  17. }
  18. }

代码示例来源:origin: cflint/CFLint

  1. /**
  2. * Parse a CF argument tag to see if any of the arguments names are invalid.
  3. */
  4. @Override
  5. public void element(final Element element, final Context context, final BugList bugs) {
  6. if (element.getName().equals(CF.CFARGUMENT)) {
  7. final int lineNo = context.startLine();
  8. int offset = context.offset();
  9. final String name = element.getAttributeValue(CF.NAME);
  10. if (name != null && name.length() > 0) {
  11. offset = element.getAttributes().get(CF.NAME).getValueSegment().getBegin();
  12. checkNameForBugs(context, name, context.getFilename(), context.getFunctionName(), lineNo, offset, bugs);
  13. } else {
  14. context.addMessage("ARGUMENT_MISSING_NAME", null, this, lineNo, offset);
  15. }
  16. }
  17. }

代码示例来源:origin: cflint/CFLint

  1. /**
  2. * Parse a CF argument tag to see if any of the arguments names are invalid.
  3. */
  4. @Override
  5. public void element(final Element element, final Context context, final BugList bugs) {
  6. if (element.getName().equals(CF.CFARGUMENT)) {
  7. final int lineNo = context.startLine();
  8. int offset = context.offset();
  9. final String name = element.getAttributeValue(CF.NAME);
  10. if (name != null && name.length() > 0) {
  11. offset = element.getAttributes().get(CF.NAME).getValueSegment().getBegin();
  12. checkNameForBugs(context, name, context.getFilename(), context.getFunctionName(), lineNo, offset, bugs);
  13. } else {
  14. context.addMessage("ARGUMENT_MISSING_NAME", null, this, lineNo, offset);
  15. }
  16. }
  17. }

代码示例来源:origin: cflint/CFLint

  1. private void checkCFLoopName(final Element element, final Context context, final BugList bugs, final int begLine, int offset) {
  2. if (element.getAttributeValue(CF.INDEX) != null || element.getAttributeValue(CF.ITEM) != null) {
  3. String varName = "";
  4. final String index = element.getAttributeValue(CF.INDEX);
  5. final String item = element.getAttributeValue(CF.ITEM);
  6. if (index != null) {
  7. varName = index;
  8. offset = element.getAttributes().get(CF.INDEX).getValueSegment().getBegin();
  9. }
  10. else if (item != null) {
  11. varName = item;
  12. offset = element.getAttributes().get(CF.ITEM).getValueSegment().getBegin();
  13. }
  14. checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine,
  15. offset, bugs,null);
  16. }
  17. }

代码示例来源:origin: cflint/CFLint

  1. private void checkCFLoopName(final Element element, final Context context, final BugList bugs, final int begLine, int offset) {
  2. if (element.getAttributeValue(CF.INDEX) != null || element.getAttributeValue(CF.ITEM) != null) {
  3. String varName = "";
  4. final String index = element.getAttributeValue(CF.INDEX);
  5. final String item = element.getAttributeValue(CF.ITEM);
  6. if (index != null) {
  7. varName = index;
  8. offset = element.getAttributes().get(CF.INDEX).getValueSegment().getBegin();
  9. }
  10. else if (item != null) {
  11. varName = item;
  12. offset = element.getAttributes().get(CF.ITEM).getValueSegment().getBegin();
  13. }
  14. checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine,
  15. offset, bugs,null);
  16. }
  17. }

代码示例来源:origin: cflint/CFLint

  1. private void checkCFName(final Element element, final Context context, final BugList bugs, final int begLine, int offset, final String name) {
  2. if (element.getAttributeValue(name) != null) {
  3. final Attribute attribute = element.getAttributes().get(name);
  4. String varName;
  5. if (attribute != null) {
  6. varName = attribute.getValue();
  7. offset = attribute.getValueSegment().getBegin();
  8. } else {
  9. varName = "";
  10. }
  11. checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine, offset, bugs,null);
  12. }
  13. }

代码示例来源:origin: cflint/CFLint

  1. private void checkCFName(final Element element, final Context context, final BugList bugs, final int begLine, int offset, final String name) {
  2. if (element.getAttributeValue(name) != null) {
  3. final Attribute attribute = element.getAttributes().get(name);
  4. String varName;
  5. if (attribute != null) {
  6. varName = attribute.getValue();
  7. offset = attribute.getValueSegment().getBegin();
  8. } else {
  9. varName = "";
  10. }
  11. checkNameForBugs(context, varName, varName, context.getFilename(), context.getFunctionName(), begLine, offset, bugs,null);
  12. }
  13. }

代码示例来源:origin: com.github.cfparser/cfml.parsing

  1. public ParserTag(net.htmlparser.jericho.Tag tag) {
  2. setName(tag.getName());
  3. setBegin(tag.getElement().getEnd());
  4. setEnd(tag.getElement().getBegin());
  5. setStartTagBegin(tag.getElement().getStartTag().getBegin());
  6. setStartTagEnd(tag.getElement().getStartTag().getEnd());
  7. if (tag.getElement().getEndTag() != null) {
  8. setEndTagBegin(tag.getElement().getEndTag().getBegin());
  9. setEndTagEnd(tag.getElement().getEndTag().getEnd());
  10. } else {
  11. setEndTagBegin(tag.getElement().getStartTag().getBegin());
  12. setEndTagEnd(tag.getElement().getStartTag().getEnd());
  13. }
  14. setAttributes(tag.getElement().getAttributes());
  15. }

相关文章