本文整理汇总了Java中com.sun.source.doctree.AttributeTree类的典型用法代码示例。如果您正苦于以下问题:Java AttributeTree类的具体用法?Java AttributeTree怎么用?Java AttributeTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeTree类属于com.sun.source.doctree包,在下文中一共展示了AttributeTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitStartElement
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
@Override
public Void visitStartElement(StartElementTree node, Void p) {
print("<");
print(node.getName());
java.util.List<? extends DocTree> attrs = node.getAttributes();
if (!attrs.isEmpty()) {
print(" ");
for (DocTree docTree : attrs) {
doAccept((DCTree)docTree);
}
DocTree last = attrs.get(attrs.size() - 1);
if (node.isSelfClosing() && last instanceof AttributeTree
&& ((AttributeTree) last).getValueKind() == ValueKind.UNQUOTED)
print(" ");
}
if (node.isSelfClosing())
print("/");
print(">");
return null;
}
示例2: validateHtml4Attrs
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
private void validateHtml4Attrs(AttributeTree tree, Name name, AttrKind k) {
switch (k) {
case ALL:
case HTML4:
break;
case INVALID:
env.messages.error(HTML, tree, "dc.attr.unknown", name);
break;
case OBSOLETE:
env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete", name);
break;
case USE_CSS:
env.messages.warning(ACCESSIBILITY, tree, "dc.attr.obsolete.use.css", name);
break;
case HTML5:
env.messages.error(HTML, tree, "dc.attr.not.supported.html4", name);
break;
}
}
示例3: rewriteChildren
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
protected final AttributeTree rewriteChildren(AttributeTree tree) {
AttributeTree value = tree;
List<? extends DocTree> vl = translateDoc(tree.getValue());
if (vl != tree.getValue()) {
value = make.Attribute((Name) tree.getName(), tree.getValueKind(), vl);
}
return value;
}
示例4: visitAttribute
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
@Override
public Void visitAttribute(AttributeTree node, Void p) {
print(node.getName());
String quote;
switch (node.getValueKind()) {
case EMPTY:
return null;
case UNQUOTED:
quote = "";
break;
case SINGLE:
quote = "'";
break;
case DOUBLE:
quote = "\"";
break;
default:
throw new AssertionError();
}
print("=");
print(quote);
for (DocTree docTree : node.getValue()) {
doAccept((DCTree)docTree);
}
print(quote);
return null;
}
示例5: getAttrValue
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
private String getAttrValue(AttributeTree tree) {
if (tree.getValue() == null)
return null;
StringWriter sw = new StringWriter();
try {
new DocPretty(sw).print(tree.getValue());
} catch (IOException e) {
// cannot happen
}
// ignore potential use of entities for now
return sw.toString();
}
示例6: checkURI
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
private void checkURI(AttributeTree tree, String uri) {
try {
URI u = new URI(uri);
} catch (URISyntaxException e) {
env.messages.error(HTML, tree, "dc.invalid.uri", uri);
}
}
示例7: validateHtml5Attrs
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
private void validateHtml5Attrs(AttributeTree tree, Name name, AttrKind k) {
switch (k) {
case ALL:
case HTML5:
break;
case INVALID:
case OBSOLETE:
case USE_CSS:
case HTML4:
env.messages.error(HTML, tree, "dc.attr.not.supported.html5", name);
break;
}
}
示例8: checkURI
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
private void checkURI(AttributeTree tree, String uri) {
// allow URIs beginning with javascript:, which would otherwise be rejected by the URI API.
if (uri.startsWith("javascript:"))
return;
try {
URI u = new URI(uri);
} catch (URISyntaxException e) {
env.messages.error(HTML, tree, "dc.invalid.uri", uri);
}
}
示例9: visitAttribute
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
@Override
public DocTree visitAttribute(AttributeTree tree, Object p) {
return rewriteChildren(tree);
}
示例10: Attribute
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
public AttributeTree Attribute(CharSequence name, AttributeTree.ValueKind vkind, List<? extends DocTree> value) {
return docMake.at(NOPOS).newAttributeTree((Name) names.fromString(name.toString()), vkind, value);
}
示例11: visitAttribute
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
/**
* @since 1.47
*/
@Override
public DocTree visitAttribute(AttributeTree node, Element p) {
return docScanner.visitAttribute(node, p, null);
}
示例12: visitAttribute
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
@Override
public Void visitAttribute(AttributeTree node, List<ErrorDescription> errors) {
return super.visitAttribute(node, errors);
}
示例13: visitAttribute
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
@Override @DefinedBy(Api.COMPILER_TREE)
public Void visitAttribute(AttributeTree tree, Consumer<DocTreePath> f) {
String name = tree.getName().toString().toLowerCase(Locale.ENGLISH);
switch (name) {
// See https://www.w3.org/TR/html-markup/global-attributes.html#common.attrs.event-handler
case "onabort": case "onblur": case "oncanplay": case "oncanplaythrough":
case "onchange": case "onclick": case "oncontextmenu": case "ondblclick":
case "ondrag": case "ondragend": case "ondragenter": case "ondragleave":
case "ondragover": case "ondragstart": case "ondrop": case "ondurationchange":
case "onemptied": case "onended": case "onerror": case "onfocus": case "oninput":
case "oninvalid": case "onkeydown": case "onkeypress": case "onkeyup":
case "onload": case "onloadeddata": case "onloadedmetadata": case "onloadstart":
case "onmousedown": case "onmousemove": case "onmouseout": case "onmouseover":
case "onmouseup": case "onmousewheel": case "onpause": case "onplay":
case "onplaying": case "onprogress": case "onratechange": case "onreadystatechange":
case "onreset": case "onscroll": case "onseeked": case "onseeking":
case "onselect": case "onshow": case "onstalled": case "onsubmit": case "onsuspend":
case "ontimeupdate": case "onvolumechange": case "onwaiting":
// See https://www.w3.org/TR/html4/sgml/dtd.html
// Most of the attributes that take a %Script are also defined as event handlers
// in HTML 5. The one exception is onunload.
// case "onchange": case "onclick": case "ondblclick": case "onfocus":
// case "onkeydown": case "onkeypress": case "onkeyup": case "onload":
// case "onmousedown": case "onmousemove": case "onmouseout": case "onmouseover":
// case "onmouseup": case "onreset": case "onselect": case "onsubmit":
case "onunload":
f.accept(getCurrentPath());
break;
// See https://www.w3.org/TR/html4/sgml/dtd.html
// https://www.w3.org/TR/html5/
// These are all the attributes that take a %URI or a valid URL potentially surrounded
// by spaces
case "action": case "cite": case "classid": case "codebase": case "data":
case "datasrc": case "for": case "href": case "longdesc": case "profile":
case "src": case "usemap":
List<? extends DocTree> value = tree.getValue();
if (value != null && !value.isEmpty() && value.get(0).getKind() == Kind.TEXT) {
String v = value.get(0).toString().trim().toLowerCase(Locale.ENGLISH);
if (v.startsWith("javascript:")) {
f.accept(getCurrentPath());
}
}
break;
}
return super.visitAttribute(tree, f);
}
示例14: Attribute
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
/**Creates the DocTree's HTML AttributeTree.
*
* @param name attribute name
* @param vkind attribute value kid
* @param value attribute value
* @return newly created AttributeTree
* @since 0.124
*/
public AttributeTree Attribute(CharSequence name, AttributeTree.ValueKind vkind, List<? extends DocTree> value) {
return delegate.Attribute(name, vkind, value);
}
示例15: newAttributeTree
import com.sun.source.doctree.AttributeTree; //导入依赖的package包/类
/**
* Create a new {@code AttributeTree} object, to represent an HTML attribute in an HTML tag.
* @param name the name of the attribute
* @param vkind the kind of attribute value
* @param value the value, if any, of the attribute
* @return an {@code AttributeTree} object
*/
AttributeTree newAttributeTree(Name name, ValueKind vkind, List<? extends DocTree> value);