本文整理了Java中nu.xom.Element.getAttributeValue()
方法的一些代码示例,展示了Element.getAttributeValue()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Element.getAttributeValue()
方法的具体详情如下:
包路径:nu.xom.Element
类名称:Element
方法名:getAttributeValue
暂无
代码示例来源:origin: wiztools/rest-client
private static ContentType getContentType(Element e) {
String contentType = e.getAttributeValue("content-type");
String charsetStr = e.getAttributeValue("charset");
if(StringUtil.isNotEmpty(contentType)) {
return new ContentTypeBean(contentType,
(charsetStr!=null? Charset.forName(charsetStr): null));
}
else {
return null;
}
}
}
代码示例来源:origin: com.thoughtworks.xstream/xstream
public String getAttribute(String name) {
return currentElement.getAttributeValue(encodeAttribute(name));
}
代码示例来源:origin: wiztools/rest-client
private Map<String, String> getHeadersFromHeaderNode(final Element node)
throws XMLException {
Map<String, String> m = new LinkedHashMap<>();
for (int i = 0; i < node.getChildElements().size(); i++) {
Element headerElement = node.getChildElements().get(i);
if (!"header".equals(headerElement.getQualifiedName())) {
throw new XMLException("<headers> element should contain only <header> elements");
}
m.put(headerElement.getAttributeValue("key"),
headerElement.getAttributeValue("value"));
}
return m;
}
代码示例来源:origin: wiztools/rest-client
private ReqEntityMultipartBean getMultipart(Element e) {
final String subTypeStr = e.getAttributeValue("subtype");
final MultipartSubtype subType = subTypeStr!=null?
MultipartSubtype.valueOf(subTypeStr): MultipartSubtype.FORM_DATA;
final String mode = e.getAttributeValue("mode");
MultipartMode format = StringUtil.isNotEmpty(mode)?
MultipartMode.valueOf(mode): null;
List<ReqEntityPart> parts = getMultipartParts(e);
return new ReqEntityMultipartBean(parts, format, subType);
}
代码示例来源:origin: wiztools/rest-client
private List<HttpCookie> getCookiesFromCookiesNode(final Element node)
throws XMLException {
List<HttpCookie> out = new ArrayList<>();
for (int i = 0; i < node.getChildElements().size(); i++) {
Element e = node.getChildElements().get(i);
if(!"cookie".equals(e.getQualifiedName())) {
throw new XMLException("<cookies> element should contain only <cookie> elements");
}
HttpCookie cookie = new HttpCookie(e.getAttributeValue("name"),
e.getAttributeValue("value"));
final String cookieVerStr = e.getAttributeValue("version");
if(StringUtil.isNotEmpty(cookieVerStr)) {
cookie.setVersion(Integer.parseInt(cookieVerStr));
}
else {
cookie.setVersion(CookieVersion.DEFAULT_VERSION.getIntValue());
}
out.add(cookie);
}
return out;
}
代码示例来源:origin: stanfordnlp/CoreNLP
String docID = docElem.getAttributeValue("id");
Matcher matcher = datePattern.matcher(docID);
matcher.find();
代码示例来源:origin: wiztools/rest-client
private ReqEntityPart getMultipartPart(Element e) {
final String name = e.getLocalName();
final String partName = e.getAttributeValue("name");
final ContentType ct = getContentType(e);
String fileName = e.getAttributeValue("filename");
代码示例来源:origin: wiztools/rest-client
final SSLKeyStoreBean keyStore = new SSLKeyStoreBean();
final String typeStr = e.getAttributeValue("type");
if(StringUtil.isNotEmpty(typeStr))
keyStore.setType(KeyStoreType.valueOf(typeStr));
keyStore.setFile(new File(e.getAttributeValue("file")));
keyStore.setPassword(Util.base64decode(e.getAttributeValue("password")).toCharArray());
out.setKeyStore(keyStore);
break;
final SSLKeyStoreBean trustStore = new SSLKeyStoreBean();
final String typeStr = e.getAttributeValue("type");
if(StringUtil.isNotEmpty(typeStr))
trustStore.setType(KeyStoreType.valueOf(typeStr));
trustStore.setFile(new File(e.getAttributeValue("file")));
trustStore.setPassword(Util.base64decode(e.getAttributeValue("password")).toCharArray());
out.setTrustStore(trustStore);
break;
代码示例来源:origin: wiztools/rest-client
public static List<Request> getRequestCollectionFromXMLFile(final File f)
throws IOException, XMLException {
XmlPersistenceRead xUtlRead = new XmlPersistenceRead();
List<Request> out = new ArrayList<>();
Document doc = xUtlRead.getDocumentFromFile(f);
Element eRoot = doc.getRootElement();
if(!"request-collection".equals(eRoot.getLocalName())) {
throw new XMLException("Expecting root element <request-collection>, but found: "
+ eRoot.getLocalName());
}
final String version = eRoot.getAttributeValue("version");
try {
Versions.versionValidCheck(version);
}
catch(Versions.VersionValidationException ex) {
throw new XMLException(ex);
}
xUtlRead.setReadVersion(version);
Elements eRequests = doc.getRootElement().getChildElements();
for(int i=0; i<eRequests.size(); i++) {
Element eRequest = eRequests.get(i);
Request req = xUtlRead.getRequestBean(eRequest);
out.add(req);
}
return out;
}
代码示例来源:origin: wiztools/rest-client
Versions.versionValidCheck(rootNode.getAttributeValue("version"));
} else if ("status".equals(nodeName)) {
responseBean.setStatusLine(tNode.getValue());
responseBean.setStatusCode(Integer.parseInt(tNode.getAttributeValue("code")));
} else if ("headers".equals(nodeName)) {
Map<String, String> m = getHeadersFromHeaderNode(tNode);
代码示例来源:origin: wiztools/rest-client
protected Request xml2Request(final Document doc)
throws MalformedURLException, XMLException {
// get the rootNode
Element rootNode = doc.getRootElement();
if (!"rest-client".equals(rootNode.getQualifiedName())) {
throw new XMLException("Root node is not <rest-client>");
}
// checking correct rest version
final String rcVersion = rootNode.getAttributeValue("version");
try {
Versions.versionValidCheck(rcVersion);
}
catch(Versions.VersionValidationException ex) {
throw new XMLException(ex);
}
readVersion = rcVersion;
// if more than two request element is present then throw the exception
if (rootNode.getChildElements().size() != 1) {
throw new XMLException("There can be only one child node for root node: <request>");
}
// minimum one request element is present in xml
if (rootNode.getFirstChildElement("request") == null) {
throw new XMLException("The child node of <rest-client> should be <request>");
}
Element requestNode = rootNode.getFirstChildElement("request");
return getRequestBean(requestNode);
}
代码示例来源:origin: x-stream/xstream
@Override
public String getAttribute(final String name) {
return currentElement.getAttributeValue(encodeAttribute(name));
}
代码示例来源:origin: org.codehaus.mojo/emma-maven-plugin
/**
* Get full class name (package + class) for "class" XML element.
*
* @param elem The element.
* @return the full class name (package + class) for "class" XML element.
*/
private String fullClassName( Element elem )
{
final Element packageElem = (Element) elem.getParent().getParent();
final String packageName = packageElem.getAttributeValue( "name" );
final String className = elem.getAttributeValue( "name" );
return packageName.length() != 0 ? packageName + "." + className : className;
}
代码示例来源:origin: org.xml-cml/cmlxom
void createPattern() {
List<Node> patterns = CMLUtil.getQueryNodes(simpleType, "./"
+ XSD_RESTRICTION + CMLConstants.S_SLASH + XSD_PATTERN, XPATH_XSD);
if (patterns.size() > 0) {
pattern = ((Element) patterns.get(0)).getAttributeValue("value");
}
}
代码示例来源:origin: org.xml-cml/cmlxom
private static void copyAttributeTo(Element from, Element to, String attName) {
String attVal = from.getAttributeValue(attName);
if (attVal != null) {
to.addAttribute(new Attribute(attName, attVal));
}
}
代码示例来源:origin: org.xml-cml/cmlxom
/** constructor.
* @param xsdElement
*/
public CMLElementType(Element xsdElement) {
init();
this.xsdElement = xsdElement;
this.name = xsdElement.getAttributeValue("name");
processContentTypes();
}
代码示例来源:origin: cmu-phil/tetrad
private static void setNodeMeans(Element variablesElement, SemIm im) {
Elements vars = variablesElement.getChildElements(SemXmlConstants.CONTINUOUS_VARIABLE);
for (int i = 0; i < vars.size(); i++) {
Element var = vars.get(i);
Node node = im.getSemPm().getGraph().getNode(var.getAttributeValue(SemXmlConstants.NAME));
if (var.getAttributeValue(SemXmlConstants.MEAN) != null) {
im.setMean(node, Double.parseDouble(var.getAttributeValue(SemXmlConstants.MEAN)));
} else {
return;
}
}
}
代码示例来源:origin: org.xml-cml/cmlxom
private static double getWeight(Element element, String source) {
Elements weights = element.getChildElements("mass");
for (int i = 0; i < weights.size(); i++) {
Element weight = (Element) weights.get(i);
if (source != null
&& source.equals(weight.getAttributeValue("source"))) {
return Double.parseDouble(weight.getValue());
}
}
return 0;
}
代码示例来源:origin: concordion/concordion
private String categorize(Element row) {
String cssClass = row.getAttributeValue("class");
if (cssClass == null) {
Element cell = (Element) row.query("td").get(0);
cssClass = cell.getAttributeValue("class");
}
Check.notNull(cssClass, "cssClass is null");
return cssClass.toUpperCase();
}
代码示例来源:origin: net.sf.opendse/opendse-io
protected Attributes toAttributes(nu.xom.Element eAttributes) throws IllegalArgumentException, SecurityException,
InstantiationException, IllegalAccessException, InvocationTargetException, NoSuchMethodException,
ClassNotFoundException {
Attributes attributes = new Attributes();
nu.xom.Elements eAttributeList = eAttributes.getChildElements("attribute", SpecificationWriter.NS);
for (nu.xom.Element element : iterable(eAttributeList)) {
String name = element.getAttributeValue("name");
Object value = toAttribute(element);
attributes.put(name, value);
}
return attributes;
}
内容来源于网络,如有侵权,请联系作者删除!