本文整理汇总了Java中org.jdom.filter.ElementFilter类的典型用法代码示例。如果您正苦于以下问题:Java ElementFilter类的具体用法?Java ElementFilter怎么用?Java ElementFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ElementFilter类属于org.jdom.filter包,在下文中一共展示了ElementFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cut
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
public static void cut(Document doc) {
// Iterate over all salary elements
Iterator<?> iterator = doc.getDescendants(new ElementFilter("salary"));
// Snapshot these elements before modification
List<Element> elems = new LinkedList<Element>();
while (iterator.hasNext())
elems.add((Element)iterator.next());
// Iterate over salary elements and cut salaries
for (Element elem : elems) {
Double salary = Double.valueOf(elem.getText());
elem.setText(Double.toString(salary/2));
}
}
示例2: parseReturn
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
private Hashtable parseReturn(InputStream is){
Hashtable h = null;
try {
SAXBuilder parser = new SAXBuilder();
Document doc = parser.build(is);
Element root = doc.getRootElement();
h = new Hashtable();
String jsessionID =g(root.getDescendants(new ElementFilter("jsessionID")));
String ptLoginToken =g(root.getDescendants(new ElementFilter("ptLoginToken")));
String returnCode =g(root.getDescendants(new ElementFilter("returnCode")));
h.put("returnCode",returnCode);
h.put("ptLoginToken",ptLoginToken);
h.put("jsessionID",jsessionID);
}catch(Exception e){
MiscUtils.getLogger().error("Error", e);
}
return h;
}
示例3: init
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
public void init() {
Iterator extentIt = getDescendants(new ElementFilter("extent", gmd));
Element extent;
if ( extentIt.hasNext() ) {
extent = (Element) extentIt.next();
geographic = extent.getChild("EX_Extent", gmd).getChild("geographicElement", gmd).getChild("EX_GeographicBoundingBox", gmd);
Element verticalParent = extent.getChild("EX_Extent", gmd).getChild("verticalElement", gmd);
if ( verticalParent != null ) {
vertical = verticalParent.getChild("EX_VerticalExtent", gmd);
}
Element timeouter = extent.getChild("EX_Extent", gmd).getChild("temporalElement", gmd);
if ( timeouter != null ) {
time = timeouter.getChild("EX_TemporalExtent", gmd);
}
}
}
示例4: getStringValues
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
private List<String> getStringValues(String elementName, String name) {
List<String> values = new ArrayList<String>();
Element root = getRootElement();
Iterator elements = root.getDescendants(new ElementFilter(elementName));
if ( root == null ) {
return values;
}
while ( elements.hasNext() ) {
Element e = (Element) elements.next();
String ename = e.getAttributeValue("name");
if (ename != null && ename.equals(name) ) {
List<Element> strs = e.getChildren("str");
for ( Iterator strIt = strs.iterator(); strIt.hasNext(); ) {
Element str = (Element) strIt.next();
String value = str.getTextTrim();
if ( value != null ) {
values.add(value);
}
}
}
}
return values;
}
示例5: setResourceMetadataXml
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
public void setResourceMetadataXml(Element the_md) {
// version 1 and higher are different formats, hence a slightly weird test
Iterator mdroles = the_md.getDescendants(new ElementFilter("intendedEndUserRole", ns.lom_ns()));
if (mdroles != null) {
while (mdroles.hasNext()) {
Element role = (Element)mdroles.next();
Iterator values = role.getDescendants(new ElementFilter("value", ns.lom_ns()));
if (values != null) {
while (values.hasNext()) {
if (roles == null)
roles = new HashSet<String>();
Element value = (Element)values.next();
String roleName = value.getTextTrim();
roles.add(roleName);
}
}
}
}
if (log.isDebugEnabled())
log.debug("resource md xml: "+the_md);
}
示例6: stripEmptyElements
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
private static void stripEmptyElements(Element asXML) {
int childCount = asXML.getContent().size();
int index = 0;
while (index < childCount) {
Content child = asXML.getContent(index);
if (child instanceof Element) {
Element childElement = (Element) child;
if (childElement.getName().equals("port")) {
index++;
} else if (childElement.getDescendants(new ElementFilter("port")).hasNext()) {
stripEmptyElements(childElement);
index++;
} else {
asXML.removeContent(childElement);
childCount--;
}
}
}
}
示例7: extractXMLelement
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
/**
* Extracts the contents of the named XML element from a parent
*
* @param parentElement The parent element
* @param theElement Name of the XML element to be extracted
* @return
* @throws IOException
* @throws JDOMException
*/
public static Element extractXMLelement(Element parentElement, String theElement) throws JDOMException, IOException {
Filter elementFilter = new ElementFilter();
List<Element> children = parentElement.getContent(elementFilter);
for (Element element : children) {
if (element.getName().equalsIgnoreCase(theElement)) {
return element;
}
Element child = extractXMLelement(element, theElement);
if (child != null) {
return child;
}
}
return null;
}
示例8: ingestError
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
private Document ingestError(Document error){
Iterator i = error.getDescendants(new ElementFilter(DAP4.ERROR,DAP4.NS));
if(i.hasNext()){
Element e = (Element)i.next();
e.detach();
// error.detachRootElement();
// error.setRootElement(e);
ingestError(e);
return error;
}
else
return null;
}
示例9: getFieldIDs
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
/**
* Gets the wcs:Identifier of each wcs:Field in this wcs:Coverage.
* @return An array of strings containing the values of each wcs:Identifier of each wcs:Field in this wcs:Coverage.
*/
public String[] getFieldIDs(){
Vector<String> fIDs = new Vector<String>();
Element field, identifier;
String id;
Iterator i = myCD.getDescendants(new ElementFilter("Field",WCS.WCS_NS));
while(i.hasNext()){
field = (Element) i.next();
identifier = field.getChild("Identifier",WCS.WCS_NS);
if(identifier!=null){
id = identifier.getTextTrim();
fIDs.add(id);
}
}
String[] fieldIDs = new String[fIDs.size()];
return fIDs.toArray(fieldIDs);
}
示例10: getFields
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
public Vector<Field> getFields() throws WcsException {
Element rangeType;
rangeType = _myCD.getChild("rangeType",WCS.GMLCOV_NS);
if(rangeType==null)
throw new WcsException("wcs:CoverageDescription is missing a gmlcov:rangeType: ",
WcsException.MISSING_PARAMETER_VALUE,"gmlcov:rangeType");
Vector<Field> fields = new Vector<>();
ElementFilter filter = new ElementFilter("field",WCS.SWE_NS);
Iterator i = rangeType.getDescendants(filter);
while(i.hasNext()){
Element fieldElement = (Element) i.next();
Field field = new Field(fieldElement);
fields.add(field);
}
return fields;
}
示例11: getNcmlDatasetElements
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
public static Vector<Element> getNcmlDatasetElements(Element catalog){
Vector<Element> ncmlDatasets = new Vector<Element>();
Iterator alldatasets = catalog.getDescendants(new ElementFilter(THREDDS.DATASET, THREDDS.NS));
Iterator ncmlContent;
Element dataset;
while(alldatasets.hasNext()){
dataset = (Element) alldatasets.next();
ncmlContent = dataset.getDescendants(new ElementFilter(NCML.NS));
if(ncmlContent.hasNext())
ncmlDatasets.add(dataset);
}
return ncmlDatasets;
}
示例12: BESError
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
public BESError(Document error, MediaType mt) {
this();
setResponseMediaType(mt);
Iterator i = error.getDescendants(new ElementFilter(BES_ERROR));
if(i.hasNext()){
Element e = (Element)i.next();
e.detach();
error.detachRootElement();
error.setRootElement(e);
}
besErrorDoc = processError(error);
}
示例13: processError
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
private Document processError(Document error){
Iterator i = error.getDescendants(new ElementFilter(BES_ERROR));
if(i.hasNext()){
Element e = (Element)i.next();
e.detach();
error.detachRootElement();
error.setRootElement(e);
processError(e);
return error;
}
else
return null;
}
示例14: getDatasetScanServiceElements
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
private Vector<Element> getDatasetScanServiceElements() throws JDOMException, SaxonApiException, IOException {
Vector<Element> services = new Vector<>();
Iterator<Element> i = _sourceDatasetScanElement.getDescendants(new ElementFilter(THREDDS.SERVICE_NAME, THREDDS.NS));
while(i.hasNext()){
Element serviceNameElement = i.next();
String serviceName = serviceNameElement.getTextTrim();
Element service = getServiceByName(serviceName);
if (service == null ) {
_log.error("getDatasetScanServiceElements() - Unable to locate service named '{}'. Skipping.",serviceName);
}
else {
services.add(service);
}
}
return services;
}
示例15: getXmlChild
import org.jdom.filter.ElementFilter; //导入依赖的package包/类
public static Element getXmlChild(Element root, String name) {
Element child = null;
List<Element> elements = null;
if (name != null) {
ElementFilter elementFilter = new ElementFilter(name);
Iterator<Element> iter = (Iterator<Element>)root.getDescendants(elementFilter);
if (iter.hasNext()) {
child = iter.next();
}
} else {
elements = (List<Element>)root.getChildren();
if (elements.size() >= 1) {
child = elements.get(0);
}
}
return child;
}