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

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

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

Element.getAttributeValue介绍

[英]Returns the CharacterReference#decode(CharSequence) value of the attribute with the specified name (case insensitive).

Returns null if the #getStartTag() does not StartTagType#hasAttributes(), no attribute with the specified name exists or the attribute Attribute#hasValue().

This is equivalent to #getStartTag(). StartTag#getAttributeValue(String).
[中]返回具有指定名称(不区分大小写)的属性的CharacterReference#decode(CharSequence)值。
返回null如果#getStartTag()未启动tTagType#hasAttributes(),则不存在具有指定名称的属性或属性#hasValue()。
这相当于#getStartTag().StartTag#getAttributeValue(字符串)。

代码示例

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

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (// element.getName().equals(CF.CFCOMPONENT) ||
  4. element.getName().equals(CF.CFFUNCTION)) {
  5. final String outputAttr = element.getAttributeValue(CF.OUTPUT);
  6. if (outputAttr == null) {
  7. context.addMessage("OUTPUT_ATTR", element.getAttributeValue(CF.NAME));
  8. }
  9. }
  10. }
  11. }

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

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (// element.getName().equals(CF.CFCOMPONENT) ||
  4. element.getName().equals(CF.CFFUNCTION)) {
  5. final String outputAttr = element.getAttributeValue(CF.OUTPUT);
  6. if (outputAttr == null) {
  7. context.addMessage("OUTPUT_ATTR", element.getAttributeValue(CF.NAME));
  8. }
  9. }
  10. }
  11. }

代码示例来源: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);
  5. final String variableType = element.getAttributeValue(CF.TYPE);
  6. if (variableType == null) {
  7. context.addMessage("ARG_TYPE_MISSING", name);
  8. } else if ("any".equals(variableType)) {
  9. context.addMessage("ARG_TYPE_ANY", name);
  10. }
  11. }
  12. }

代码示例来源: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);
  5. final String variableType = element.getAttributeValue(CF.TYPE);
  6. if (variableType == null) {
  7. context.addMessage("ARG_TYPE_MISSING", name);
  8. } else if ("any".equals(variableType)) {
  9. context.addMessage("ARG_TYPE_ANY", name);
  10. }
  11. }
  12. }

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

  1. @SuppressWarnings("unchecked")
  2. private void checkAttributes(final Element element, final CFLintConfiguration configuration) {
  3. for (String tagInfo : (List<String>)configuration.getParameter(this,"usedTagAttributes", List.class)) {
  4. final String[] parts = (tagInfo + "//").split("/");
  5. if (element.getName() != null && parts[0].equalsIgnoreCase(element.getName())) {
  6. final String name = element.getAttributeValue(parts[1]);
  7. if (name != null && localVariables.containsKey(name.toLowerCase())) {
  8. localVariables.put(name.toLowerCase(), new VarInfo(name, true));
  9. }
  10. }
  11. }
  12. }

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

  1. @SuppressWarnings("unchecked")
  2. private void checkAttributes(final Element element, final CFLintConfiguration configuration) {
  3. for (String tagInfo : (List<String>)configuration.getParameter(this,"usedTagAttributes", List.class)) {
  4. final String[] parts = (tagInfo + "//").split("/");
  5. if (element.getName() != null && parts[0].equalsIgnoreCase(element.getName())) {
  6. final String name = element.getAttributeValue(parts[1]);
  7. if (name != null && localVariables.containsKey(name.toLowerCase())) {
  8. localVariables.put(name.toLowerCase(), new VarInfo(name, true));
  9. }
  10. }
  11. }
  12. }

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

  1. /**
  2. * Parse a CF function tag declaration to see if it's missing a hint.
  3. */
  4. @Override
  5. public void element(final Element element, final Context context, final BugList bugs) {
  6. if (element.getName().equals(CF.CFFUNCTION)) {
  7. final String hint = element.getAttributeValue("hint");
  8. if (hint == null || hint.trim().isEmpty()) {
  9. context.addMessage(FUNCTION_HINT_MISSING, context.getFunctionName());
  10. }
  11. }
  12. }

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

  1. /**
  2. * Parse a CF component tag declaration to see if it's missing a hint.
  3. */
  4. @Override
  5. public void element(final Element element, final Context context, final BugList bugs) {
  6. if (element.getName().equals(CF.CFCOMPONENT)) {
  7. final String hint = element.getAttributeValue(CF.HINT);
  8. if (hint == null || hint.trim().isEmpty()) {
  9. context.addMessage(COMPONENT_HINT_MISSING, context.calcComponentName());
  10. }
  11. }
  12. }

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

  1. /**
  2. * Parse a CF component tag declaration to see if it's missing a hint.
  3. */
  4. @Override
  5. public void element(final Element element, final Context context, final BugList bugs) {
  6. if (element.getName().equals(CF.CFCOMPONENT)) {
  7. final String hint = element.getAttributeValue(CF.HINT);
  8. if (hint == null || hint.trim().isEmpty()) {
  9. context.addMessage(COMPONENT_HINT_MISSING, context.calcComponentName());
  10. }
  11. }
  12. }

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

  1. /**
  2. * Parse a CF function tag declaration to see if it's missing a hint.
  3. */
  4. @Override
  5. public void element(final Element element, final Context context, final BugList bugs) {
  6. if (element.getName().equals(CF.CFFUNCTION)) {
  7. final String hint = element.getAttributeValue("hint");
  8. if (hint == null || hint.trim().isEmpty()) {
  9. context.addMessage(FUNCTION_HINT_MISSING, context.getFunctionName());
  10. }
  11. }
  12. }

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

  1. private final boolean anyContainingCFOutputHasQuery(final Element element) {
  2. if (element == null) {
  3. return false;
  4. }
  5. if (element.getAttributeValue(CF.QUERY) != null) {
  6. return true;
  7. }
  8. return anyContainingCFOutputHasQuery(CFTool.getNamedParent(element, CF.CFOUTPUT));
  9. }

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

  1. private final boolean anyContainingCFOutputHasQuery(final Element element) {
  2. if (element == null) {
  3. return false;
  4. }
  5. if (element.getAttributeValue(CF.QUERY) != null) {
  6. return true;
  7. }
  8. return anyContainingCFOutputHasQuery(CFTool.getNamedParent(element, CF.CFOUTPUT));
  9. }

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

  1. private static String getOptionLabel(final Element optionElement) {
  2. final String labelAttributeValue=optionElement.getAttributeValue("label");
  3. if (labelAttributeValue!=null) return labelAttributeValue;
  4. return CharacterReference.decodeCollapseWhiteSpace(optionElement.getContent());
  5. }
  6. private final class OptionElementIterator implements Iterator<Element> {

代码示例来源:origin: mozilla/zest

  1. private String getReturnValue(Element element) throws ZestAssignFailException {
  2. if (returnElement) {
  3. return element.getContent().toString();
  4. } else if (returnAttribute) {
  5. return element.getAttributeValue(returnedAttributeName);
  6. } else {
  7. throw new ZestAssignFailException(this, "A selection method must be configured");
  8. }
  9. }

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

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (element.getName().equals(CF.CFFUNCTION)) {
  4. final int begLine = element.getSource().getRow(element.getBegin());
  5. final String functionType = element.getAttributeValue("returnType");
  6. checkReturnType(functionType, begLine, context, bugs);
  7. }
  8. }

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

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (element.getName().equals(CF.CFFUNCTION)) {
  4. final int begLine = element.getSource().getRow(element.getBegin());
  5. final String functionType = element.getAttributeValue("returnType");
  6. checkReturnType(functionType, begLine, context, bugs);
  7. }
  8. }

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

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (element.getName().equals(CF.CFCOMPONENT)) {
  4. final String name = context.getComponentName();
  5. final String nameAttribute = element.getAttributeValue(CF.NAME);
  6. if (nameAttribute != null) {
  7. didYouMeanDisplayName(name, element.getSource().getRow(element.getBegin()), context.offset() + element.getBegin(), context, bugs);
  8. }
  9. }
  10. }

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

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (element.getName().equals(CF.CFCOMPONENT)) {
  4. final String name = context.getComponentName();
  5. final String nameAttribute = element.getAttributeValue(CF.NAME);
  6. if (nameAttribute != null) {
  7. didYouMeanDisplayName(name, element.getSource().getRow(element.getBegin()), context.offset() + element.getBegin(), context, bugs);
  8. }
  9. }
  10. }

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

  1. @Override
  2. public void element(final Element element, final Context context, final BugList bugs) {
  3. if (element.getName().equals(CF.CFOUTPUT)) {
  4. final Element parent = CFTool.getNamedParent(element, CF.CFOUTPUT);
  5. if (parent != null) {
  6. if (parent.getAttributeValue(CF.GROUP) == null && anyContainingCFOutputHasQuery(parent)) {
  7. element.getSource().getRow(element.getBegin());
  8. element.getSource().getColumn(element.getBegin());
  9. context.addMessage("NESTED_CFOUTPUT", "");
  10. }
  11. }
  12. }
  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.CFOUTPUT)) {
  4. final Element parent = CFTool.getNamedParent(element, CF.CFOUTPUT);
  5. if (parent != null) {
  6. if (parent.getAttributeValue(CF.GROUP) == null && anyContainingCFOutputHasQuery(parent)) {
  7. element.getSource().getRow(element.getBegin());
  8. element.getSource().getColumn(element.getBegin());
  9. context.addMessage("NESTED_CFOUTPUT", "");
  10. }
  11. }
  12. }
  13. }

相关文章