Java Code Examples for org.w3c.dom.NamedNodeMap

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/model/quests/operations/.

Source file: NextStateOperation.java

  32 
vote

public NextStateOperation(Node node){
  super(node);
  NamedNodeMap attr=node.getAttributes();
  long state;
  try {
    state=Long.parseLong(attr.getNamedItem("state").getNodeValue());
  }
 catch (  Exception e) {
    state=0;
  }
  this.nextState=state;
}
 

Example 2

From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.

Source file: ServerConfigParser.java

  32 
vote

protected String getAttributeValue(Node node,String attrName){
  NamedNodeMap attrs=node.getAttributes();
  Node attrNode=attrs.getNamedItem(attrName);
  if (attrNode != null) {
    return attrNode.getNodeValue();
  }
  return "";
}
 

Example 3

From project any23, under directory /core/src/main/java/org/apache/any23/extractor/html/.

Source file: DomUtils.java

  32 
vote

/** 
 * Reads the value of the specified <code>attribute</code>, returning the <code>defaultValue</code> string if not present.
 * @param node node to read the attribute.
 * @param attribute attribute name.
 * @param defaultValue the default value to return if attribute is not found.
 * @return the attribute value or <code>defaultValue</code> if not found.
 */
public static String readAttribute(Node node,String attribute,String defaultValue){
  NamedNodeMap attributes=node.getAttributes();
  if (null == attributes)   return defaultValue;
  Node attr=attributes.getNamedItem(attribute);
  if (null == attr)   return defaultValue;
  return attr.getNodeValue();
}
 

Example 4

From project C-Cat, under directory /util/src/main/java/gov/llnl/ontology/text/corpora/.

Source file: NYTDocumentReader.java

  32 
vote

private static String getAttributeValue(Node node,String attributeName){
  NamedNodeMap attributes=node.getAttributes();
  if (attributes != null) {
    Node attribute=attributes.getNamedItem(attributeName);
    if (attribute != null)     return attribute.getNodeValue();
  }
  return null;
}
 

Example 5

From project cilia-workbench, under directory /cilia-workbench-common/src/fr/liglab/adele/cilia/workbench/common/xml/.

Source file: XMLHelpers.java

  32 
vote

public static Map<String,String> findAttributesValues(Node node){
  Map<String,String> retval=new HashMap<String,String>();
  NamedNodeMap attrs=node.getAttributes();
  if (attrs != null) {
    for (int i=0; i < attrs.getLength(); i++) {
      Node attr=attrs.item(i);
      String name=attr.getNodeName();
      String value=attr.getNodeValue();
      retval.put(name,value);
    }
  }
  return retval;
}
 

Example 6

From project Cilia_1, under directory /framework/runtime/src/main/java/fr/liglab/adele/cilia/admin/impl/.

Source file: CiliaChainInstanceParser.java

  32 
vote

protected String getType(Node node){
  NamedNodeMap attribs=node.getAttributes();
  if (attribs == null) {
    return null;
  }
  Node nodeType=attribs.getNamedItem("type");
  String type=null;
  if (nodeType != null) {
    type=nodeType.getNodeValue();
  }
  return type;
}
 

Example 7

From project core_1, under directory /config/src/main/java/org/switchyard/config/.

Source file: DOMConfiguration.java

  32 
vote

/** 
 * {@inheritDoc}
 */
@Override public List<String> getAttributeNames(){
  List<String> names=new ArrayList<String>();
  NamedNodeMap attrs=_element.getAttributes();
  for (int i=0; i < attrs.getLength(); i++) {
    Attr attr=(Attr)attrs.item(i);
    String name=XMLHelper.nameOf(attr);
    names.add(name);
  }
  return names;
}
 

Example 8

From project Core_2, under directory /parser-xml/src/main/java/org/jboss/forge/parser/xml/.

Source file: XMLParser.java

  32 
vote

private static void readAttributes(final Node target,final org.w3c.dom.Node source){
  final NamedNodeMap attributes=source.getAttributes();
  if (attributes != null) {
    for (int i=0; i < attributes.getLength(); i++) {
      final org.w3c.dom.Node attribute=attributes.item(i);
      target.attribute(attribute.getNodeName(),attribute.getNodeValue());
    }
  }
}
 

Example 9

From project des, under directory /daemon/lib/apache-log4j-1.2.16/src/main/java/org/apache/log4j/lf5/viewer/configure/.

Source file: ConfigurationManager.java

  32 
vote

protected void processRecordFilter(Document doc){
  NodeList nodeList=doc.getElementsByTagName(NDCTEXTFILTER);
  Node n=nodeList.item(0);
  if (n == null) {
    return;
  }
  NamedNodeMap map=n.getAttributes();
  String text=getValue(map,NAME);
  if (text == null || text.equals("")) {
    return;
  }
  _monitor.setNDCLogRecordFilter(text);
}
 

Example 10

From project descriptors, under directory /spi/src/main/java/org/jboss/shrinkwrap/descriptor/spi/node/dom/.

Source file: XmlDomNodeImporterImpl.java

  32 
vote

private void readAttributes(final Node target,final org.w3c.dom.Node source){
  final NamedNodeMap attributes=source.getAttributes();
  if (attributes != null) {
    for (int i=0; i < attributes.getLength(); i++) {
      final org.w3c.dom.Node attribute=attributes.item(i);
      target.attribute(attribute.getNodeName(),attribute.getNodeValue());
    }
  }
}
 

Example 11

From project dozer, under directory /eclipse-plugin/net.sf.dozer.eclipse.plugin/src/org/dozer/eclipse/plugin/editorpage/utils/.

Source file: DOMUtils.java

  32 
vote

/** 
 * Replace node name of <code>element</code> with new name <code>newNodeName</code>.
 * @param element
 * @param newNodeName
 * @return
 */
public static Element replaceNodeName(Element element,String newNodeName){
  Document document=element.getOwnerDocument();
  Element element2=document.createElement(newNodeName);
  NamedNodeMap attrs=element.getAttributes();
  for (int i=0; i < attrs.getLength(); i++) {
    Attr attr2=(Attr)document.importNode(attrs.item(i),true);
    element2.getAttributes().setNamedItem(attr2);
  }
  while (element.hasChildNodes()) {
    element2.appendChild(element.getFirstChild());
  }
  element.getParentNode().replaceChild(element2,element);
  return element2;
}
 

Example 12

From project eclipsefp, under directory /net.sf.eclipsefp.haskell.core/src/net/sf/eclipsefp/haskell/core/internal/project/.

Source file: Parser.java

  32 
vote

private static String getValue(final Element rootElement,final String tagName,final String attributeName){
  String result="";
  NodeList list=rootElement.getElementsByTagName(tagName);
  if (list.getLength() > 0) {
    NamedNodeMap attributes=list.item(0).getAttributes();
    Node pathNode=attributes.getNamedItem(attributeName);
    result=pathNode.getNodeValue();
  }
  return result;
}
 

Example 13

From project emite, under directory /src/main/java/com/calclab/emite/base/xml/.

Source file: XMLPacketImpl.java

  32 
vote

@Override public ImmutableMap<String,String> getAttributes(){
  final ImmutableMap.Builder<String,String> result=ImmutableMap.builder();
  final NamedNodeMap attribs=element.getAttributes();
  for (int i=0; i < attribs.getLength(); i++) {
    final Attr attrib=(Attr)attribs.item(i);
    result.put(attrib.getName(),attrib.getValue());
  }
  return result.build();
}
 

Example 14

From project empire-db, under directory /empire-db/src/main/java/org/apache/empire/xml/.

Source file: XMLUtil.java

  32 
vote

/** 
 * Changes the tag name of an element.
 * @param elem Element which name should be changed
 * @param newName new tag name of the element
 * @return true if the name was changed successfully or false otherwise
 */
static public boolean changeTagName(Element elem,String newName){
  if (elem == null)   return false;
  Document doc=elem.getOwnerDocument();
  Element newElem=doc.createElement(newName);
  NamedNodeMap attrs=elem.getAttributes();
  for (int i=0; i < attrs.getLength(); i++) {
    Attr attr2=(Attr)doc.importNode(attrs.item(i),true);
    newElem.getAttributes().setNamedItem(attr2);
  }
  for (Node node=elem.getFirstChild(); node != null; node=node.getNextSibling())   newElem.appendChild(node.cloneNode(true));
  Node parent=elem.getParentNode();
  parent.replaceChild(newElem,elem);
  return true;
}
 

Example 15

From project fitnesse, under directory /src/util/.

Source file: XmlWriter.java

  32 
vote

private String writeAttributes(Element element){
  StringBuffer attributeString=new StringBuffer();
  NamedNodeMap attributeMap=element.getAttributes();
  int length=attributeMap.getLength();
  for (int i=0; i < length; i++) {
    Attr attributeNode=(Attr)attributeMap.item(i);
    String name=attributeNode.getName();
    String value=attributeNode.getValue();
    attributeString.append(" ").append(name).append("=\"").append(value).append("\"");
  }
  return attributeString.toString();
}
 

Example 16

From project Gemini-Blueprint, under directory /core/src/main/java/org/eclipse/gemini/blueprint/config/internal/.

Source file: CollectionBeanDefinitionParser.java

  32 
vote

/** 
 * Parse &lt;osgi:natural&gt; element.
 * @param element
 * @return
 */
protected Comparator parseNaturalComparator(Element element){
  Comparator comparator=null;
  NamedNodeMap attributes=element.getAttributes();
  for (int x=0; x < attributes.getLength(); x++) {
    Attr attribute=(Attr)attributes.item(x);
    String name=attribute.getLocalName();
    String value=attribute.getValue();
    if (BASIS.equals(name)) {
      if (SERVICE_REFERENCE_ORDER.equals(value))       return SERVICE_REFERENCE_COMPARATOR;
 else       if (SERVICE_ORDER.equals(value))       return null;
    }
  }
  return comparator;
}
 

Example 17

From project geronimo-xbean, under directory /xbean-blueprint/src/main/java/org/apache/xbean/blueprint/context/impl/.

Source file: XBeanNamespaceHandler.java

  32 
vote

private void attributeProperties(Element element,ParserContext parserContext,String beanTypeName,MutableBeanMetadata beanMetaData){
  NamedNodeMap attrs=element.getAttributes();
  for (int i=0; i < attrs.getLength(); i++) {
    Attr attr=(Attr)attrs.item(i);
    if (namespace.equals(attr.getNamespaceURI()) || attr.getNamespaceURI() == null) {
      String attrName=attr.getLocalName();
      String value=attr.getValue().trim();
      String propertyName=mappingMetaData.getPropertyName(beanTypeName,attrName);
      String propertyEditor=mappingMetaData.getPropertyEditor(beanTypeName,attrName);
      addProperty(propertyName,value,propertyEditor,beanMetaData,parserContext);
    }
  }
}
 

Example 18

From project Guit, under directory /src/main/java/com/guit/junit/dom/.

Source file: ElementMock.java

  32 
vote

@Override public String toString(){
  StringBuilder sb=new StringBuilder();
  NamedNodeMap attributes=e.getAttributes();
  for (int i=0; i < attributes.getLength(); i++) {
    Node attr=attributes.item(i);
    sb.append(" " + attr.getNodeName() + "=\""+ attr.getNodeValue()+ "\"");
  }
  String tagName=e.getTagName();
  return "<" + tagName + " "+ sb.toString()+ ">"+ getInnerXml(e)+ "</"+ tagName+ ">";
}
 

Example 19

From project hawtjni, under directory /hawtjni-generator/src/main/java/org/fusesource/hawtjni/generator/.

Source file: MacGenerator.java

  32 
vote

public Node getIDAttribute(Node node){
  NamedNodeMap attributes=node.getAttributes();
  if (attributes == null)   return null;
  String[] names=getIDAttributeNames();
  for (int i=0; i < names.length; i++) {
    Node nameAttrib=attributes.getNamedItem(names[i]);
    if (nameAttrib != null)     return nameAttrib;
  }
  return null;
}
 

Example 20

From project hdiv, under directory /hdiv-config/src/main/java/org/hdiv/config/xml/.

Source file: ConfigBeanDefinitionParser.java

  32 
vote

private void processMapping(Node node,Map map){
  NamedNodeMap attributes=node.getAttributes();
  String url=attributes.getNamedItem("url").getTextContent();
  String parameters=attributes.getNamedItem("parameters").getTextContent();
  map.put(url,this.convertToList(parameters));
}
 

Example 21

From project Ivory_1, under directory /src/java/main/ivory/core/util/.

Source file: XMLTools.java

  32 
vote

public static String getAttributeValue(Node node,String name){
  if (node == null || !node.hasAttributes()) {
    return null;
  }
  NamedNodeMap attributes=node.getAttributes();
  if (attributes.getNamedItem(name) == null) {
    return null;
  }
  return attributes.getNamedItem(name).getNodeValue();
}
 

Example 22

From project ivyde, under directory /org.apache.ivyde.eclipse/src/java/org/apache/ivyde/eclipse/cpcontainer/.

Source file: IvyClasspathContainerSerializer.java

  32 
vote

private IAccessRule readAccessRule(Node ruleNode) throws SAXException {
  NamedNodeMap attributes=ruleNode.getAttributes();
  int kind=Integer.parseInt(getAttribute(attributes,KIND));
  IPath pattern=new Path(getAttribute(attributes,PATTERN));
  return JavaCore.newAccessRule(pattern,kind);
}
 

Example 23

From project jackrabbit-oak, under directory /oak-core/src/main/java/org/apache/jackrabbit/oak/security/privilege/.

Source file: PrivilegeDefinitionReader.java

  32 
vote

/** 
 * Update the specified nsRegistry mappings with the nsRegistry declarations defined by the given XML element.
 * @param elem
 * @param nsRegistry
 * @throws javax.jcr.RepositoryException
 */
private static void updateNamespaceMapping(Element elem,NamespaceRegistry nsRegistry) throws RepositoryException {
  NamedNodeMap attributes=elem.getAttributes();
  for (int i=0; i < attributes.getLength(); i++) {
    Attr attr=(Attr)attributes.item(i);
    if (attr.getName().startsWith(ATTR_XMLNS)) {
      String prefix=attr.getName().substring(ATTR_XMLNS.length());
      String uri=attr.getValue();
      nsRegistry.registerNamespace(prefix,uri);
    }
  }
}
 

Example 24

From project jangaroo-tools, under directory /exml/exml-compiler/src/main/java/net/jangaroo/exml/parser/.

Source file: ExmlToModelParser.java

  32 
vote

private void fillModelAttributes(ExmlModel model,JsonObject jsonObject,Node componentNode,ConfigClass configClass){
  NamedNodeMap attributes=componentNode.getAttributes();
  for (int i=0; i < attributes.getLength(); i++) {
    Attr attribute=(Attr)attributes.item(i);
    String attributeName=attribute.getLocalName();
    String attributeValue=attribute.getValue();
    ConfigAttribute configAttribute=getCfgByName(configClass,attributeName);
    jsonObject.set(attributeName,getAttributeValue(attributeValue,configAttribute == null ? null : configAttribute.getType()));
  }
  fillModelAttributesFromSubElements(model,jsonObject,componentNode,configClass);
}
 

Example 25

From project jcollectd, under directory /src/main/java/org/collectd/mx/.

Source file: MBeanConfig.java

  32 
vote

private String getAttribute(Node node,String name){
  NamedNodeMap attrs=node.getAttributes();
  if (attrs == null) {
    return null;
  }
  Node item=attrs.getNamedItem(name);
  if (item == null) {
    return null;
  }
  return item.getNodeValue();
}
 

Example 26

From project jgraphx, under directory /src/com/mxgraph/io/.

Source file: mxObjectCodec.java

  32 
vote

/** 
 * Decodes all attributes of the given node using decodeAttribute.
 */
protected void decodeAttributes(mxCodec dec,Node node,Object obj){
  NamedNodeMap attrs=node.getAttributes();
  if (attrs != null) {
    for (int i=0; i < attrs.getLength(); i++) {
      Node attr=attrs.item(i);
      decodeAttribute(dec,attr,obj);
    }
  }
}
 

Example 27

From project jOOX, under directory /jOOX/src/main/java/org/joox/.

Source file: Util.java

  32 
vote

/** 
 * Get an attribute value if it exists, or <code>null</code>
 */
static final String attr(Element element,String name,boolean ignoreNamespace){
  NamedNodeMap attributes=element.getAttributes();
  for (int i=0; i < attributes.getLength(); i++) {
    String localName=attributes.item(i).getNodeName();
    if (ignoreNamespace) {
      localName=stripNamespace(localName);
    }
    if (name.equals(localName)) {
      return attributes.item(i).getNodeValue();
    }
  }
  return null;
}
 

Example 28

From project jpropel-light, under directory /src/propel/core/utils/.

Source file: XmlUtils.java

  32 
vote

/** 
 * Parses the node for a given attribute. The comparison type can be specified, e.g. OrdinalIgnoreCase. If the attribute is not found, null is returned.
 */
private static Node findAttributeEquals(Node node,String attributeName,StringComparison comparisonType){
  NamedNodeMap attributes=node.getAttributes();
  for (int i=0; i < attributes.getLength(); i++) {
    Node attr=attributes.item(i);
    String name=attr.getNodeName();
    if (!StringUtils.isNullOrEmpty(name))     if (StringUtils.equal(name,attributeName,comparisonType))     return attr;
  }
  return null;
}
 

Example 29

From project jumpnevolve, under directory /lib/slick/src/org/newdawn/slick/util/xml/.

Source file: XMLElement.java

  32 
vote

/** 
 * Get the names of the attributes specified on this element
 * @return The names of the elements specified
 */
public String[] getAttributeNames(){
  NamedNodeMap map=dom.getAttributes();
  String[] names=new String[map.getLength()];
  for (int i=0; i < names.length; i++) {
    names[i]=map.item(i).getNodeName();
  }
  return names;
}
 

Example 30

From project l2jserver2, under directory /l2jserver2-common/src/main/java/com/l2jserver/service/core/logging/.

Source file: Log4JLoggingService.java

  32 
vote

@Override protected void doStart() throws ServiceStartException {
  final Layout layout=new PatternLayout("[%p %d] %c{1} - %m%n");
  rootLogger=Logger.getRootLogger();
  rootLogger.removeAllAppenders();
  rootLogger.addAppender(new ConsoleAppender(layout,"System.err"));
  final NodeList nodes=config.getLoggersNode().getChildNodes();
  for (int i=0; i < nodes.getLength(); i++) {
    final Node node=nodes.item(i);
    if (!"logger".equals(node.getNodeName()))     continue;
    final NamedNodeMap attributes=node.getAttributes();
    final Logger logger=Logger.getLogger(attributes.getNamedItem("name").getNodeValue());
    logger.setLevel(Level.toLevel(attributes.getNamedItem("level").getNodeValue()));
  }
}
 

Example 31

From project lib-gwt-svg, under directory /src/main/java/com/google/gwt/uibinder/rebind/.

Source file: XMLElement.java

  32 
vote

private String getOpeningTag(){
  StringBuilder b=new StringBuilder().append("<").append(elem.getTagName());
  NamedNodeMap attrs=elem.getAttributes();
  for (int i=0; i < attrs.getLength(); i++) {
    Attr attr=(Attr)attrs.item(i);
    b.append(String.format(" %s='%s'",attr.getName(),UiBinderWriter.escapeAttributeText(attr.getValue())));
  }
  b.append(">");
  return b.toString();
}
 

Example 32

From project libra, under directory /tests/org.eclipse.libra.facet.test/src/org/eclipse/libra/facet/test/.

Source file: WebContextRootSynchronizerTest.java

  32 
vote

private Element getContextRootProperty(Element webModuleElement){
  NodeList webModuleElementProperties=webModuleElement.getElementsByTagName("property");
  for (int i=0; i < webModuleElementProperties.getLength(); i++) {
    Element property=(Element)webModuleElementProperties.item(i);
    NamedNodeMap attributes=property.getAttributes();
    Attr nameAttribute=(Attr)attributes.getNamedItem("name");
    if (nameAttribute.getNodeValue().equals("context-root")) {
      return property;
    }
  }
  return null;
}
 

Example 33

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/context/.

Source file: ProxyRuntimeContext.java

  31 
vote

/** 
 * ??amoeba.xml?dbServerList???dbServer?????
 * @param current
 * @return
 */
private DBServerConfig loadServer(Element current){
  DBServerConfig serverConfig=new DBServerConfig();
  NamedNodeMap nodeMap=current.getAttributes();
  Map<String,Object> map=new HashMap<String,Object>();
  for (int i=0; i < nodeMap.getLength(); i++) {
    Node node=nodeMap.item(i);
    if (node instanceof org.w3c.dom.Attr) {
      Attr attr=(Attr)node;
      map.put(attr.getName(),attr.getNodeValue());
    }
  }
  ParameterMapping.mappingObject(serverConfig,map);
  BeanObjectEntityConfig factory=DocumentUtil.loadBeanConfig(DocumentUtil.getTheOnlyElement(current,"factoryConfig"));
  BeanObjectEntityConfig pool=DocumentUtil.loadBeanConfig(DocumentUtil.getTheOnlyElement(current,"poolConfig"));
  if (pool != null) {
    serverConfig.setPoolConfig(pool);
  }
  if (factory != null) {
    serverConfig.setFactoryConfig(factory);
  }
  return serverConfig;
}
 

Example 34

From project androidquery, under directory /src/com/androidquery/util/.

Source file: XmlDom.java

  31 
vote

private void serialize(Element e,XmlSerializer s,int depth,String spaces) throws Exception {
  String name=e.getTagName();
  writeSpace(s,depth,spaces);
  s.startTag("",name);
  if (e.hasAttributes()) {
    NamedNodeMap nm=e.getAttributes();
    for (int i=0; i < nm.getLength(); i++) {
      Attr attr=(Attr)nm.item(i);
      s.attribute("",attr.getName(),attr.getValue());
    }
  }
  if (e.hasChildNodes()) {
    NodeList nl=e.getChildNodes();
    int elements=0;
    for (int i=0; i < nl.getLength(); i++) {
      Node n=nl.item(i);
      short type=n.getNodeType();
switch (type) {
case Node.ELEMENT_NODE:
        serialize((Element)n,s,depth + 1,spaces);
      elements++;
    break;
case Node.TEXT_NODE:
  s.text(text(n));
break;
case Node.CDATA_SECTION_NODE:
s.cdsect(text(n));
break;
}
}
if (elements > 0) {
writeSpace(s,depth,spaces);
}
}
s.endTag("",name);
}
 

Example 35

From project apps-for-android, under directory /CLiCkin2DaBeaT/src/com/google/clickin2dabeat/.

Source file: C2B.java

  31 
vote

private void runC2B(Document c2b){
  Node root=c2b.getElementsByTagName("c2b").item(0);
  title=root.getAttributes().getNamedItem("title").getNodeValue();
  author=root.getAttributes().getNamedItem("author").getNodeValue();
  level=root.getAttributes().getNamedItem("level").getNodeValue();
  media=root.getAttributes().getNamedItem("media").getNodeValue();
  NodeList beats=c2b.getElementsByTagName("beat");
  targets=new ArrayList<Target>();
  for (int i=0; i < beats.getLength(); i++) {
    NamedNodeMap attribs=beats.item(i).getAttributes();
    double time=Double.parseDouble(attribs.getNamedItem("time").getNodeValue());
    int x=Integer.parseInt(attribs.getNamedItem("x").getNodeValue());
    int y=Integer.parseInt(attribs.getNamedItem("y").getNodeValue());
    String colorStr=attribs.getNamedItem("color").getNodeValue();
    targets.add(new Target(time,x,y,colorStr));
  }
  if ((beats.getLength() == 0) || forceEditMode) {
    displayCreateLevelAlert();
  }
 else {
    videoUri=Uri.parse(media);
    background.setVideoURI(videoUri);
  }
}
 

Example 36

From project Archimedes, under directory /br.org.archimedes.io.xml/src/br/org/archimedes/io/xml/parsers/.

Source file: LayerParser.java

  31 
vote

/** 
 * Extracts the attributes from a container node and create the corresponding layer.
 * @param parsingNode The container node
 * @return The layer extracted from this container
 */
private Layer parseLayerProperties(Node parsingNode){
  NamedNodeMap attributes=parsingNode.getAttributes();
  Node nameNode=attributes.getNamedItem("name");
  String name=nameNode.getNodeValue();
  Node lineStyleNode=attributes.getNamedItem("lineStyle");
  int lineStyle=Integer.parseInt(lineStyleNode.getNodeValue());
  Node thicknessNode=attributes.getNamedItem("thickness");
  double thickness=XMLUtils.nodeToDouble(thicknessNode);
  LineStyle[] styles=LineStyle.values();
  Layer layer=new Layer(Constant.WHITE,name,styles[lineStyle],thickness);
  Node visibleNode=attributes.getNamedItem("visible");
  if (visibleNode != null) {
    boolean visible=Boolean.parseBoolean(visibleNode.getNodeValue());
    layer.setVisible(visible);
  }
  Node lockedNode=attributes.getNamedItem("locked");
  if (lockedNode != null) {
    boolean locked=Boolean.parseBoolean(lockedNode.getNodeValue());
    layer.setLocked(locked);
  }
  return layer;
}
 

Example 37

From project autopsy, under directory /RecentActivity/src/org/sleuthkit/autopsy/recentactivity/.

Source file: SearchEngineURLQueryAnalyzer.java

  31 
vote

private void createEngines(){
  NodeList nlist=xmlinput.getElementsByTagName("SearchEngine");
  SearchEngineURLQueryAnalyzer.SearchEngine[] listEngines=new SearchEngineURLQueryAnalyzer.SearchEngine[nlist.getLength()];
  for (int i=0; i < nlist.getLength(); i++) {
    try {
      NamedNodeMap nnm=nlist.item(i).getAttributes();
      String EngineName=nnm.getNamedItem("engine").getNodeValue();
      String EnginedomainSubstring=nnm.getNamedItem("domainSubstring").getNodeValue();
      Map<String,String> splits=new HashMap<String,String>();
      NodeList listSplits=xmlinput.getElementsByTagName("splitToken");
      for (int k=0; k < listSplits.getLength(); k++) {
        if (listSplits.item(k).getParentNode().getAttributes().getNamedItem("engine").getNodeValue().equals(EngineName)) {
          splits.put(listSplits.item(k).getAttributes().getNamedItem("plainToken").getNodeValue(),listSplits.item(k).getAttributes().getNamedItem("regexToken").getNodeValue());
        }
      }
      SearchEngineURLQueryAnalyzer.SearchEngine Se=new SearchEngineURLQueryAnalyzer.SearchEngine(EngineName,EnginedomainSubstring,splits);
      System.out.println("Search Engine: " + Se.toString());
      listEngines[i]=Se;
    }
 catch (    Exception e) {
      logger.log(Level.WARNING,"Unable to create search engines!",e);
    }
  }
  engines=listEngines;
}
 

Example 38

From project blueprint-namespaces, under directory /blueprint/blueprint-core/src/main/java/org/apache/aries/blueprint/container/.

Source file: Parser.java

  31 
vote

private void findNamespaces(Set<URI> namespaces,Node node){
  if (node instanceof Element || node instanceof Attr) {
    String ns=node.getNamespaceURI();
    if (ns != null && !isBlueprintNamespace(ns) && !isIgnorableAttributeNamespace(ns)) {
      namespaces.add(URI.create(ns));
    }
 else     if (ns == null && node instanceof Attr && SCOPE_ATTRIBUTE.equals(node.getNodeName()) && ((Attr)node).getOwnerElement() != null && BLUEPRINT_NAMESPACE.equals(((Attr)node).getOwnerElement().getNamespaceURI()) && BEAN_ELEMENT.equals(((Attr)node).getOwnerElement().getLocalName())) {
      URI scopeNS=getNamespaceForAttributeValue(node);
      if (scopeNS != null) {
        namespaces.add(scopeNS);
      }
    }
  }
  NamedNodeMap nnm=node.getAttributes();
  if (nnm != null) {
    for (int i=0; i < nnm.getLength(); i++) {
      findNamespaces(namespaces,nnm.item(i));
    }
  }
  NodeList nl=node.getChildNodes();
  for (int i=0; i < nl.getLength(); i++) {
    findNamespaces(namespaces,nl.item(i));
  }
}
 

Example 39

From project chukwa, under directory /src/main/java/org/apache/hadoop/chukwa/inputtools/jplugin/.

Source file: GenericChukwaMetricsList.java

  31 
vote

public void fromXml(String xml) throws Exception {
  InputSource is=new InputSource(new StringReader(xml));
  Document doc=docBuilder.parse(is);
  Element root=doc.getDocumentElement();
  setRecordType(root.getTagName());
  long timestamp=Long.parseLong(root.getAttribute("ts"));
  setTimestamp(timestamp);
  NodeList children=root.getChildNodes();
  for (int i=0; i < children.getLength(); i++) {
    if (!children.item(i).getNodeName().equals("Metrics")) {
      continue;
    }
    NamedNodeMap attrs=children.item(i).getAttributes();
    if (attrs == null) {
      continue;
    }
    GenericChukwaMetrics metrics=new GenericChukwaMetrics();
    for (int a=0; a < attrs.getLength(); a++) {
      Attr attr=(Attr)attrs.item(a);
      String name=attr.getName();
      String value=attr.getValue();
      if (name.equals("key")) {
        metrics.setKey(value);
      }
 else {
        metrics.put(name,value);
      }
    }
    addMetrics(metrics);
  }
}
 

Example 40

From project cidb, under directory /ncbieutils-access-service/src/main/java/edu/toronto/cs/cidb/ncbieutils/.

Source file: NCBIEUtilsAccessService.java

  31 
vote

private Map<String,String> getNameForId(Node source){
  Map<String,String> result=new HashMap<String,String>();
  String id=null, name=null;
  NodeList data=source.getChildNodes();
  for (int i=0; i < data.getLength(); ++i) {
    Node n=data.item(i);
    if (n.getNodeType() != Node.ELEMENT_NODE) {
      continue;
    }
    if ("Id".equals(n.getNodeName())) {
      id=n.getTextContent();
    }
 else     if ("Item".equals(n.getNodeName())) {
      NamedNodeMap attrs=n.getAttributes();
      if (attrs.getNamedItem("Name") != null && "Title".equals(attrs.getNamedItem("Name").getNodeValue())) {
        name=n.getTextContent();
      }
    }
  }
  if (id != null) {
    if (name != null) {
      result.put(id,fixCase(name));
    }
 else {
      result.put(id,id);
    }
  }
  return result;
}
 

Example 41

From project CIShell, under directory /clients/gui/org.cishell.reference.gui.menumanager/src/org/cishell/reference/gui/menumanager/menu/.

Source file: MenuAdapter.java

  31 
vote

static void printElementAttributes(Document doc){
  NodeList nl=doc.getElementsByTagName("*");
  Element e;
  Node n;
  NamedNodeMap nnm;
  String attrname;
  String attrval;
  int i, len;
  len=nl.getLength();
  for (int j=0; j < len; j++) {
    e=(Element)nl.item(j);
    System.err.println(e.getTagName() + ":");
    nnm=e.getAttributes();
    if (nnm != null) {
      for (i=0; i < nnm.getLength(); i++) {
        n=nnm.item(i);
        attrname=n.getNodeName();
        attrval=n.getNodeValue();
        System.err.print(" " + attrname + " = "+ attrval);
      }
    }
    System.err.println();
  }
}
 

Example 42

From project Codeable_Objects, under directory /SoftObjects/src/com/ui/.

Source file: SVGReader.java

  31 
vote

private boolean parseLines(Document doc){
  NodeList nList=doc.getElementsByTagName("line");
  for (int i=0; i < nList.getLength(); i++) {
    Node nNode=nList.item(i);
    if (nNode.hasAttributes()) {
      NamedNodeMap map=nNode.getAttributes();
      String x1Value=map.getNamedItem("x1").getNodeValue();
      String y1Value=map.getNamedItem("y1").getNodeValue();
      String x2Value=map.getNamedItem("x2").getNodeValue();
      String y2Value=map.getNamedItem("y2").getNodeValue();
      if (x1Value != "" || y1Value != "" || x2Value != "" || y2Value != " ") {
        double x1=stringToDouble(x1Value);
        double y1=stringToDouble(y1Value);
        double x2=stringToDouble(x2Value);
        double y2=stringToDouble(y2Value);
        Line line=new Line(x1,y1,x2,y2);
        pattern.addLine(line);
      }
    }
  }
  return true;
}
 

Example 43

From project com.cedarsoft.serialization, under directory /test-utils/src/main/java/com/cedarsoft/serialization/test/utils/.

Source file: XmlNamespaceTranslator.java

  31 
vote

public void translateNamespaces(@Nonnull Document xmlDoc,boolean addNsToAttributes){
  Stack<Node> nodes=new Stack<Node>();
  nodes.push(xmlDoc.getDocumentElement());
  while (!nodes.isEmpty()) {
    Node node=nodes.pop();
switch (node.getNodeType()) {
case Node.ATTRIBUTE_NODE:
case Node.ELEMENT_NODE:
      Value<String> value=this.translations.get(new Key<String>(node.getNamespaceURI()));
    if (value != null) {
      node=xmlDoc.renameNode(node,value.getValue(),node.getNodeName());
    }
  break;
}
if (addNsToAttributes) {
NamedNodeMap attributes=node.getAttributes();
if (!(attributes == null || attributes.getLength() == 0)) {
  for (int i=0, count=attributes.getLength(); i < count; ++i) {
    Node attribute=attributes.item(i);
    if (attribute != null) {
      nodes.push(attribute);
    }
  }
}
}
NodeList childNodes=node.getChildNodes();
if (!(childNodes == null || childNodes.getLength() == 0)) {
for (int i=0, count=childNodes.getLength(); i < count; ++i) {
  Node childNode=childNodes.item(i);
  if (childNode != null) {
    nodes.push(childNode);
  }
}
}
}
}
 

Example 44

From project data-bus, under directory /databus-core/src/main/java/com/inmobi/databus/.

Source file: DatabusConfigParser.java

  31 
vote

private Cluster getCluster(Element el) throws Exception {
  NamedNodeMap elementsmap=el.getAttributes();
  Map<String,String> clusterelementsmap=new HashMap<String,String>(elementsmap.getLength());
  for (int i=0; i < elementsmap.getLength(); ++i) {
    Attr attribute=(Attr)elementsmap.item(i);
    logger.info(attribute.getName() + ":" + attribute.getValue());
    clusterelementsmap.put(attribute.getName(),attribute.getValue());
  }
  String cRootDir=defaults.get(ROOTDIR);
  NodeList list=el.getElementsByTagName(ROOTDIR);
  if (list != null && list.getLength() == 1) {
    Element elem=(Element)list.item(0);
    cRootDir=elem.getTextContent();
  }
  Map<String,DestinationStream> consumeStreams=new HashMap<String,DestinationStream>();
  logger.debug("getting consume streams for Cluster ::" + clusterelementsmap.get(NAME));
  List<DestinationStream> consumeStreamList=getConsumeStreams(clusterelementsmap.get(NAME));
  if (consumeStreamList != null && consumeStreamList.size() > 0) {
    for (    DestinationStream consumeStream : consumeStreamList) {
      consumeStreams.put(consumeStream.getName(),consumeStream);
    }
  }
  if (cRootDir == null)   cRootDir=defaults.get(ROOTDIR);
  return new Cluster(clusterelementsmap,cRootDir,consumeStreams,getSourceStreams(clusterelementsmap.get(NAME)));
}
 

Example 45

From project edna-rcp, under directory /org.edna.plugingenerator/src/org/edna/plugingenerator/generator/.

Source file: WizardHelpers.java

  31 
vote

static public Map<String,String> getXSDataClassTypes(IFile uml) throws Exception {
  HashMap<String,String> xsDataClasses=new HashMap<String,String>();
  DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
  DocumentBuilder db=dbf.newDocumentBuilder();
  Document doc=db.parse(uml.getContents());
  doc.getDocumentElement().normalize();
  NodeList nodelist=doc.getElementsByTagName("packagedElement");
  for (int i=0; i < nodelist.getLength(); i++) {
    Node node=nodelist.item(i);
    NamedNodeMap attribs=node.getAttributes();
    if (attribs.getNamedItem("xmi:type").getNodeValue().equals("uml:Class") == false) {
      continue;
    }
    String name=attribs.getNamedItem("name").getNodeValue();
    String generalization="";
    NodeList children=node.getChildNodes();
    for (int j=0; j < children.getLength(); j++) {
      if (children.item(j).getNodeName().equals("generalization")) {
        try {
          NodeList c1=children.item(j).getChildNodes();
          NamedNodeMap c2=c1.item(1).getAttributes();
          String gen=c2.getNamedItem("href").getNodeValue();
          String[] split=gen.split("#");
          IFile path=uml.getParent().getFile(new Path(split[0]));
          generalization=getReferencedObject(split[1],path);
        }
 catch (        Exception e) {
          NamedNodeMap a1=children.item(j).getAttributes();
          String gen=a1.getNamedItem("general").getNodeValue();
          generalization=getReferencedObject(gen,uml);
        }
      }
    }
    xsDataClasses.put(name,generalization);
  }
  return xsDataClasses;
}
 

Example 46

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/css/extend/lib/.

Source file: DOMStaticXhtmlAttributeResolver.java

  31 
vote

public String getAttributeValue(Object o,String namespaceURI,String attrName){
  Element e=(Element)o;
  if (namespaceURI == TreeResolver.NO_NAMESPACE) {
    return e.getAttribute(attrName);
  }
 else   if (namespaceURI == null) {
    if (e.getLocalName() == null) {
      return e.getAttribute(attrName);
    }
 else {
      NamedNodeMap attrs=e.getAttributes();
      int l=attrs.getLength();
      for (int i=0; i < l; i++) {
        Attr attr=(Attr)attrs.item(i);
        if (attrName.equals(attr.getLocalName())) {
          return attr.getValue();
        }
      }
      return "";
    }
  }
 else {
    return e.getAttributeNS(namespaceURI,attrName);
  }
}
 

Example 47

From project gravitext, under directory /gravitext-xmlprod/src/main/java/com/gravitext/xml/producer/.

Source file: DOMWalker.java

  31 
vote

private void putElement(final Node node) throws IOException {
  final Namespace ns=_cache.namespace(node.getPrefix(),node.getNamespaceURI());
  final Tag tag=_cache.tag(lname(node),ns);
  _pd.startTag(tag);
  NamedNodeMap atts=node.getAttributes();
  final int end=atts.getLength();
  for (int i=0; i < end; ++i) {
    final Attr dattr=(Attr)atts.item(i);
    final String iri=dattr.getNamespaceURI();
    if (XMLNS_200_URI.equals(iri)) {
      final Namespace na=_cache.namespace(dattr.getLocalName(),dattr.getValue());
      if (na != ns)       _pd.addNamespace(na);
    }
  }
  for (int i=0; i < end; ++i) {
    final Attr dattr=(Attr)atts.item(i);
    final String iri=dattr.getNamespaceURI();
    if (!XMLNS_200_URI.equals(iri)) {
      final Attribute attr=_cache.attribute(lname(dattr),_cache.namespace(dattr.getPrefix(),iri));
      _pd.addAttr(attr,dattr.getValue());
    }
  }
  putNodeList(node.getChildNodes());
  _pd.endTag(tag);
}
 

Example 48

From project HiTune_1, under directory /chukwa-hitune-dist/src/java/org/apache/hadoop/chukwa/inputtools/jplugin/.

Source file: GenericChukwaMetricsList.java

  31 
vote

public void fromXml(String xml) throws Exception {
  InputSource is=new InputSource(new StringReader(xml));
  Document doc=docBuilder.parse(is);
  Element root=doc.getDocumentElement();
  setRecordType(root.getTagName());
  long timestamp=Long.parseLong(root.getAttribute("ts"));
  setTimestamp(timestamp);
  NodeList children=root.getChildNodes();
  for (int i=0; i < children.getLength(); i++) {
    if (!children.item(i).getNodeName().equals("Metrics")) {
      continue;
    }
    NamedNodeMap attrs=children.item(i).getAttributes();
    if (attrs == null) {
      continue;
    }
    GenericChukwaMetrics metrics=new GenericChukwaMetrics();
    for (int a=0; a < attrs.getLength(); a++) {
      Attr attr=(Attr)attrs.item(a);
      String name=attr.getName();
      String value=attr.getValue();
      if (name.equals("key")) {
        metrics.setKey(value);
      }
 else {
        metrics.put(name,value);
      }
    }
    addMetrics(metrics);
  }
}
 

Example 49

From project illumina2bam, under directory /src/uk/ac/sanger/npg/illumina/.

Source file: Lane.java

  31 
vote

/** 
 * @return an object of SAMProgramRecord for base calling program
 */
public SAMProgramRecord readBaseCallProgramRecord(){
  Node nodeSoftware;
  try {
    XPathExpression exprBaseCallSoftware=xpath.compile("/BaseCallAnalysis/Run/Software");
    nodeSoftware=(Node)exprBaseCallSoftware.evaluate(baseCallsConfigDoc,XPathConstants.NODE);
  }
 catch (  XPathExpressionException ex) {
    log.error(ex,"Problems to read base calling program /BaseCallAnalysis/Run/Software");
    return null;
  }
  NamedNodeMap nodeMapSoftware=nodeSoftware.getAttributes();
  String softwareName=nodeMapSoftware.getNamedItem("Name").getNodeValue();
  String softwareVersion=nodeMapSoftware.getNamedItem("Version").getNodeValue();
  if (softwareName == null || softwareVersion == null) {
    log.warn("No base calling program name or version returned");
  }
  SAMProgramRecord baseCallProgramConfig=new SAMProgramRecord("basecalling");
  baseCallProgramConfig.setProgramName(softwareName);
  baseCallProgramConfig.setProgramVersion(softwareVersion);
  baseCallProgramConfig.setAttribute("DS","Basecalling Package");
  return baseCallProgramConfig;
}
 

Example 50

From project iserve, under directory /iserve-parent/iserve-importer-sawsdl/src/main/java/uk/ac/open/kmi/iserve/importer/sawsdl/util/.

Source file: ModelReferenceExtractor.java

  31 
vote

public static void extractModelReferences(WSDLElement element,Model model,URI elementUri){
  if (null == model || false == model.isOpen())   return;
  Object obj=element.getExtensionAttribute(modelRefQName);
  if (obj != null) {
    processModelRefString(obj.toString(),model,elementUri);
  }
  List<UnknownExtensibilityElement> extElements=element.getExtensibilityElements();
  if (extElements != null && extElements.size() > 0) {
    for (    UnknownExtensibilityElement extElement : extElements) {
      NamedNodeMap nodeMap=extElement.getElement().getAttributes();
      if (null == nodeMap || 0 == nodeMap.getLength())       return;
      int len=nodeMap.getLength();
      for (int i=0; i < len; i++) {
        if (nodeMap.item(i) != null && nodeMap.item(i).getNodeName() != null && nodeMap.item(i).getNodeName().contains("modelReference")) {
          processModelRefString(nodeMap.item(i).getNodeValue(),model,elementUri);
        }
      }
    }
  }
}
 

Example 51

From project JavaStory, under directory /Core/src/main/java/javastory/xml/.

Source file: XmlDomWzData.java

  31 
vote

@Override public Object getData(){
  final NamedNodeMap attributes=this.node.getAttributes();
  final WzDataType type=this.getType();
switch (type) {
case DOUBLE:
    final double doubleValue=Double.parseDouble(attributes.getNamedItem("value").getNodeValue());
  return Double.valueOf(doubleValue);
case FLOAT:
final float floatValue=Float.parseFloat(attributes.getNamedItem("value").getNodeValue());
return Float.valueOf(floatValue);
case INT:
final int intValue=Integer.parseInt(attributes.getNamedItem("value").getNodeValue());
return Integer.valueOf(intValue);
case SHORT:
final short shortValue=Short.parseShort(attributes.getNamedItem("value").getNodeValue());
return Short.valueOf(shortValue);
case STRING:
case UOL:
return attributes.getNamedItem("value").getNodeValue();
case VECTOR:
final String xNode=attributes.getNamedItem("x").getNodeValue();
final String yNode=attributes.getNamedItem("y").getNodeValue();
final int x=Integer.parseInt(xNode);
final int y=Integer.parseInt(yNode);
return new Point(x,y);
case CANVAS:
final String widthNode=attributes.getNamedItem("width").getNodeValue();
final String heightNode=attributes.getNamedItem("height").getNodeValue();
final int width=Integer.parseInt(widthNode);
final int height=Integer.parseInt(heightNode);
final File file=new File(this.imageDataDir,this.getName() + ".png");
return new FileStoredPngWzCanvas(width,height,file);
}
return null;
}
 

Example 52

From project jcr-openofficeplugin, under directory /src/main/java/org/exoplatform/applications/ooplugin/dialog/.

Source file: DialogBuilder.java

  31 
vote

private void parseDialog(Node dialogNode){
  Node nameNode=getChildNode(dialogNode,XML_NAME);
  DialogModel dialog=new DialogModel(nameNode.getTextContent());
  Node propertiesNode=getChildNode(dialogNode,XML_PROPERTIES);
  NodeList properties=propertiesNode.getChildNodes();
  for (int i=0; i < properties.getLength(); i++) {
    Node curNode=properties.item(i);
    if (XML_PROPERTY.equals(curNode.getLocalName())) {
      NamedNodeMap nnm=curNode.getAttributes();
      String propertyName=nnm.getNamedItem(XML_NAME).getTextContent();
      String propertyType=nnm.getNamedItem(XML_TYPE).getTextContent();
      String propertyValue=nnm.getNamedItem(XML_VALUE).getTextContent();
      ComponentProperty property=new ComponentProperty(propertyName,propertyType,propertyValue);
      dialog.getProperties().add(property);
    }
  }
  Node componentsNode=getChildNode(dialogNode,XML_COMPONENTS);
  NodeList components=componentsNode.getChildNodes();
  for (int i=0; i < components.getLength(); i++) {
    Node curNode=components.item(i);
    if (XML_COMPONENT.equals(curNode.getLocalName())) {
      Component component=parseComponent(curNode);
      dialog.getComponents().add(component);
    }
  }
  dialogs.add(dialog);
}
 

Example 53

From project jentrata-msh, under directory /Ext/ebxml-pkg/src/main/java/hk/hku/cecid/ebms/pkg/.

Source file: PKISignatureImpl.java

  31 
vote

private void domToSoap(Element domElement,ExtensionElement element) throws SOAPException {
  final String parentPrefix=element.getSOAPElement().getElementName().getPrefix();
  final String parentNamespaceUri=element.getSOAPElement().getElementName().getURI();
  final String nsPrefix=XML_NS_DECL_PREFIX + XML_NS_SEPARATOR;
  final NodeList nodeList=domElement.getChildNodes();
  for (int i=0; i < nodeList.getLength(); i++) {
    final org.w3c.dom.Node node=nodeList.item(i);
    if (node.getNodeType() == org.w3c.dom.Node.TEXT_NODE) {
      element.getSOAPElement().addTextNode(node.getNodeValue());
    }
    if (node.getNodeType() != org.w3c.dom.Node.ELEMENT_NODE) {
      continue;
    }
    final Element child=(Element)node;
    final ExtensionElement addedChild;
    if (child.getNamespaceURI().equals(parentNamespaceUri)) {
      addedChild=element.addChildElement(child.getLocalName());
    }
 else {
      addedChild=null;
    }
    final NamedNodeMap nodeMap=child.getAttributes();
    for (int j=0; j < nodeMap.getLength(); j++) {
      final Attr attribute=(Attr)nodeMap.item(j);
      final String name=attribute.getName();
      final String value=attribute.getValue();
      if (!name.equals(nsPrefix + NAMESPACE_PREFIX_DS) && !name.startsWith(XML_NS_DECL_PREFIX)) {
        addedChild.addAttribute(soapEnvelope.createName(name),value);
      }
    }
    domToSoap(child,addedChild);
  }
}
 

Example 54

From project jinx, under directory /src/main/java/net/jeremybrooks/jinx/api/.

Source file: BlogsApi.java

  31 
vote

/** 
 * Get a list of configured blogs for the calling user. This method requires authentication with 'read' permission.
 * @param serviceId (Optional) Optionally only return blogs for a givenservice id. You can get a list of from BlogsApi.getServices().
 * @return a list of configured blogs for the calling user.
 * @throws JinxException if there are any errors.
 */
public List<Blog> getList(String serviceId) throws JinxException {
  List<Blog> list=new ArrayList<Blog>();
  Map<String,String> params=new TreeMap<String,String>();
  params.put("method","flickr.blogs.getList");
  params.put("api_key",Jinx.getInstance().getApiKey());
  if (!JinxUtils.isEmpty(serviceId)) {
    params.put("service",serviceId.trim());
  }
  Document doc=Jinx.getInstance().callFlickr(params,true);
  NodeList nodes=doc.getElementsByTagName("blog");
  if (nodes != null) {
    for (int i=0; i < nodes.getLength(); i++) {
      Blog b=new Blog();
      Node blogNode=nodes.item(i);
      NamedNodeMap attrs=blogNode.getAttributes();
      b.setId(JinxUtils.getAttribute(attrs,"id"));
      b.setName(JinxUtils.getAttribute(attrs,"name"));
      b.setService(JinxUtils.getAttribute(attrs,"service"));
      b.setNeedsPassword(JinxUtils.getAttributeAsBoolean(attrs,"needspassword"));
      b.setUrl(JinxUtils.getAttribute(attrs,"url"));
      list.add(b);
    }
  }
  return list;
}
 

Example 55

From project jMemorize, under directory /src/jmemorize/core/io/.

Source file: XmlBuilder.java

  31 
vote

/** 
 * @deprecated 
 */
public static void loadLearnHistory(Document document,LearnHistory history){
  Element rootTag=(Element)document.getElementsByTagName(STATS_ROOT).item(0);
  if (rootTag == null)   return;
  NodeList childs=rootTag.getChildNodes();
  for (int i=0; i < childs.getLength(); i++) {
    Node child=childs.item(i);
    if (child.getNodeType() != Node.ELEMENT_NODE)     continue;
    NamedNodeMap attributes=child.getAttributes();
    Date start=readDate(attributes,STATS_START);
    Date end=readDate(attributes,STATS_END);
    int passed=readInt(attributes,STATS_PASSED);
    int failed=readInt(attributes,STATS_FAILED);
    int skipped=readInt(attributes,STATS_SKIPPED);
    int relearned=readInt(attributes,STATS_RELEARNED);
    history.addSummary(start,end,passed,failed,skipped,relearned);
  }
  history.setIsLoaded(true);
}
 

Example 56

From project jSCSI, under directory /bundles/initiator/src/main/java/org/jscsi/initiator/.

Source file: Configuration.java

  31 
vote

/** 
 * Parses all global settings form the main configuration file.
 * @param root The root element of the configuration.
 */
private final void parseGlobalSettings(final Element root){
  final NodeList globalConfiguration=root.getElementsByTagName(ELEMENT_GLOBAL);
  final ResultFunctionFactory resultFunctionFactory=new ResultFunctionFactory();
  Node parameter;
  NodeList parameters;
  NamedNodeMap attributes;
  SettingEntry key;
  for (int i=0; i < globalConfiguration.getLength(); i++) {
    parameters=globalConfiguration.item(i).getChildNodes();
    for (int j=0; j < parameters.getLength(); j++) {
      parameter=parameters.item(j);
      if (parameter.getNodeType() == Node.ELEMENT_NODE) {
        attributes=parameter.getAttributes();
        key=new SettingEntry();
        key.setScope(attributes.getNamedItem(ATTRIBUTE_SCOPE).getNodeValue());
        key.setResult(resultFunctionFactory.create(attributes.getNamedItem(ATTRIBUTE_RESULT).getNodeValue()));
        key.setValue(parameter.getTextContent());
synchronized (globalConfig) {
          globalConfig.put(OperationalTextKey.valueOfEx(parameter.getNodeName()),key);
        }
      }
    }
  }
}
 

Example 57

From project jsfunit, under directory /jboss-jsfunit-analysis/src/main/java/org/jboss/jsfunit/analysis/.

Source file: ApplicationTestSuite.java

  31 
vote

/** 
 * Extract the name for the EL-resolvers defined in the config file.
 * @param applicationNode the application config dom-node
 * @param configFilePath path to the config file
 * @return a Map with el-resolver id's and classnames
 */
private Map<String,String> getElResolvers(Node applicationNode,String configFilePath){
  Map<String,String> result=new HashMap<String,String>();
  String xpathElResolver="/faces-config/application/el-resolver";
  String xpathElResolverClassName="./text()";
  String xpathElResolverIdAttributeName="id";
  NodeList elResolvers=ParserUtils.query(applicationNode,xpathElResolver,configFilePath);
  for (int i=0; i < elResolvers.getLength(); i++) {
    Node elResolver=elResolvers.item(i);
    NamedNodeMap elAttributes=elResolver.getAttributes();
    Node elResolverIdAttribute=elAttributes.getNamedItem(xpathElResolverIdAttributeName);
    String elResolverId=null;
    if (elResolverIdAttribute != null) {
      elResolverId=elResolverIdAttribute.getTextContent();
    }
    String className=ParserUtils.querySingle(elResolver,xpathElResolverClassName,configFilePath);
    if (elResolverId != null) {
      result.put(elResolverId,className);
    }
 else {
      result.put(className,className);
    }
  }
  return result;
}
 

Example 58

From project Kairos, under directory /src/java/org/apache/nutch/kairos/crf/.

Source file: AnnotationTool.java

  31 
vote

/** 
 * Parse the DOM tree and create HTML segments
 * @param node
 * @param sIndent
 */
private static void parseDOMTree(Node node,Segment segment,String domPath){
  String nodeName=node.getNodeName();
  domPath+=nodeName + "-";
  segment.setSegmentDOMPath(domPath);
  String nodeValue=node.getNodeValue();
  NamedNodeMap attrributes=node.getAttributes();
  if (attrributes != null) {
    int attributeCount=attrributes.getLength();
    for (int i=0; i < attributeCount; i++) {
      Attr item=(Attr)attrributes.item(i);
      if (item.getName().equals("href")) {
        String href=item.getValue();
        segment.setURL(href);
        break;
      }
    }
  }
  if (nodeName != null && nodeName.equals("br")) {
    segment.addLineBreak();
  }
  if (nodeName != null && nodeName.equals("hr")) {
    segment.addHorizontalLine();
  }
  if (nodeName != null && nodeValue != null && nodeName.equals("#text")) {
    segment.addSegmentText(nodeValue);
  }
  Node child=node.getFirstChild();
  while (child != null) {
    parseDOMTree(child,segment,domPath);
    child=child.getNextSibling();
  }
}
 

Example 59

From project Kayak, under directory /Kayak-ui/src/main/java/com/github/kayak/ui/connections/.

Source file: ConnectionManager.java

  31 
vote

public void loadFromFile(InputStream stream){
  try {
    DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
    DocumentBuilder db=dbf.newDocumentBuilder();
    Document doc=db.parse(stream);
    NodeList favouritesList=doc.getElementsByTagName("Favourites");
    if (favouritesList.getLength() == 1) {
      Node favouritesNode=favouritesList.item(0);
      NodeList favourites=favouritesNode.getChildNodes();
      for (int i=0; i < favourites.getLength(); i++) {
        try {
          NamedNodeMap attributes=favourites.item(i).getAttributes();
          Node nameNode=attributes.getNamedItem("name");
          String name=nameNode.getNodeValue();
          Node hostNode=attributes.getNamedItem("host");
          String host=hostNode.getNodeValue();
          Node portNode=attributes.getNamedItem("port");
          int port=Integer.parseInt(portNode.getNodeValue());
          this.favourites.add(new BusURL(host,port,name));
        }
 catch (        Exception ex) {
        }
      }
    }
  }
 catch (  Exception ex) {
    logger.log(Level.SEVERE,"Error while reading connections from file\n");
  }
}
 

Example 60

From project knicker, under directory /src/main/java/net/jeremybrooks/knicker/.

Source file: DTOBuilder.java

  31 
vote

/** 
 * Parse XML document into a list of Definition objects. <p/> XML looks like this: <definitions> <definition sequence="0"> <text>A procedure for critical evaluation; a means of determining the presence, quality, or truth of something; a trial:  a test of one's eyesight; subjecting a hypothesis to a test; a test of an athlete's endurance. </text> <partOfSpeech>noun</partOfSpeech> <score>0.0</score> <sourceDictionary>ahd-legacy</sourceDictionary> <word>test</word> </definition> <definition sequence="1"> <text>A series of questions, problems, or physical responses designed to determine knowledge, intelligence, or ability.</text> <partOfSpeech>noun</partOfSpeech> <score>0.0</score> <sourceDictionary>ahd-legacy</sourceDictionary> <word>test</word> </definition> </definitions>
 * @param doc the XML document to parse.
 * @return list of Definition objects.
 * @throws KnickerException if there are any errors.
 */
static List<Definition> buildDefinitions(Document doc) throws KnickerException {
  List<Definition> definitions=new ArrayList<Definition>();
  try {
    NodeList defNodes=doc.getElementsByTagName("definition");
    for (int i=0; i < defNodes.getLength(); i++) {
      Definition definition=new Definition();
      Node defNode=defNodes.item(i);
      NamedNodeMap nnm=defNode.getAttributes();
      definition.setSequence(Util.getAttributeAsInt(nnm,"sequence"));
      definition.setText(Util.getNamedChildTextContent(defNode,"text"));
      definition.setPartOfSpeech(Util.getNamedChildTextContent(defNode,"partOfSpeech"));
      definition.setScore(Util.getNamedChildTextContent(defNode,"score"));
      definition.setSourceDictionary(Util.getNamedChildTextContent(defNode,"sourceDictionary"));
      definition.setWord(Util.getNamedChildTextContent(defNode,"word"));
      definition.setAttributionText(Util.getNamedChildTextContent(defNode,"attributionText"));
      definitions.add(definition);
    }
  }
 catch (  Exception e) {
    throw buildKnickerException("buildDefinitions",doc,e);
  }
  return definitions;
}
 

Example 61

From project LABPipe, under directory /src/org/bultreebank/labpipe/utils/.

Source file: XmlUtils.java

  31 
vote

/** 
 * Compares the attributes of two XML <code>Node</code> objects. This method returns <code>true</code> if all attribute name-value pairs match  disregarding their order of placement.
 * @param n1    first <code>Node</code>
 * @param n2    second <code>Node</code>
 * @return  boolean
 */
public static boolean diffAttributes(Node n1,Node n2){
  NamedNodeMap n1Atts=n1.getAttributes();
  NamedNodeMap n2Atts=n2.getAttributes();
  if (n1Atts.getLength() != n2Atts.getLength()) {
    return false;
  }
  for (int i=0; i < n1Atts.getLength(); i++) {
    Node a1=n1Atts.item(i);
    Node a2Val=n2Atts.getNamedItem(a1.getNodeName());
    if (a2Val == null || !a1.getNodeValue().equals(a2Val.getNodeValue())) {
      return false;
    }
  }
  return true;
}
 

Example 62

From project lenya, under directory /org.apache.lenya.module.sitetree/src/main/java/org/apache/lenya/cms/site/tree/.

Source file: DefaultSiteTree.java

  31 
vote

/** 
 * Find a node in a subtree. The search is started at the given node. The list of ids contains the document-id split by "/".
 * @param node where to start the search
 * @param ids list of node ids
 * @return the node that matches the path given in the list of ids
 */
protected synchronized Node findNode(Node node,List ids){
  if (ids.size() < 1) {
    return node;
  }
  NodeList nodes=node.getChildNodes();
  for (int i=0; i < nodes.getLength(); i++) {
    NamedNodeMap attributes=nodes.item(i).getAttributes();
    if (attributes != null) {
      Node idAttribute=attributes.getNamedItem("id");
      if (idAttribute != null && !"".equals(idAttribute.getNodeValue()) && idAttribute.getNodeValue().equals(ids.get(0))) {
        return findNode(nodes.item(i),ids.subList(1,ids.size()));
      }
    }
  }
  return null;
}
 

Example 63

From project liquibase, under directory /liquibase-core/src/test/java/liquibase/serializer/core/xml/.

Source file: XMLChangeLogSerializerTest.java

  31 
vote

@Test public void createNode_addAutoIncrementChange() throws Exception {
  AddAutoIncrementChange change=new AddAutoIncrementChange();
  change.setSchemaName("SCHEMA_NAME");
  change.setTableName("TABLE_NAME");
  change.setColumnName("COLUMN_NAME");
  change.setColumnDataType("DATATYPE(255)");
  Element node=new XMLChangeLogSerializer(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument()).createNode(change);
  assertEquals("addAutoIncrement",node.getTagName());
  NamedNodeMap attributes=node.getAttributes();
  for (int i=0; i < attributes.getLength(); i++) {
    Node attribute=attributes.item(i);
    if (attribute.getNodeName().equals("schemaName")) {
      assertEquals("SCHEMA_NAME",attribute.getNodeValue());
    }
 else     if (attribute.getNodeName().equals("tableName")) {
      assertEquals("TABLE_NAME",attribute.getNodeValue());
    }
 else     if (attribute.getNodeName().equals("columnName")) {
      assertEquals("COLUMN_NAME",attribute.getNodeValue());
    }
 else     if (attribute.getNodeName().equals("columnDataType")) {
      assertEquals("DATATYPE(255)",attribute.getNodeValue());
    }
 else {
      fail("unexpected attribute " + attribute.getNodeName());
    }
  }
}
 

Example 64

From project agile, under directory /agile-framework/src/main/java/org/apache/catalina/util/.

Source file: DOMWriter.java

  29 
vote

/** 
 * Returns a sorted list of attributes. 
 */
protected Attr[] sortAttributes(NamedNodeMap attrs){
  int len=(attrs != null) ? attrs.getLength() : 0;
  Attr array[]=new Attr[len];
  for (int i=0; i < len; i++) {
    array[i]=(Attr)attrs.item(i);
  }
  for (int i=0; i < len - 1; i++) {
    String name=null;
    if (this.qualifiedNames) {
      name=array[i].getNodeName();
    }
 else {
      name=array[i].getLocalName();
    }
    int index=i;
    for (int j=i + 1; j < len; j++) {
      String curName=null;
      if (this.qualifiedNames) {
        curName=array[j].getNodeName();
      }
 else {
        curName=array[j].getLocalName();
      }
      if (curName.compareTo(name) < 0) {
        name=curName;
        index=j;
      }
    }
    if (index != i) {
      Attr temp=array[i];
      array[i]=array[index];
      array[index]=temp;
    }
  }
  return (array);
}
 

Example 65

From project amplafi-sworddance, under directory /src/main/java/com/sworddance/util/.

Source file: AbstractXmlParser.java

  29 
vote

protected String getAttributeString(NamedNodeMap attributes,String attributeName){
  String attributeValue=null;
  if (attributes != null) {
    Node node=attributes.getNamedItem(attributeName);
    attributeValue=node == null ? null : node.getNodeValue();
  }
  return attributeValue;
}
 

Example 66

From project jboss-common-beans, under directory /src/main/java/org/jboss/common/beans/property/.

Source file: DOMWriter.java

  29 
vote

/** 
 * Returns a sorted list of attributes. 
 */
private Attr[] sortAttributes(NamedNodeMap attrs){
  int len=(attrs != null) ? attrs.getLength() : 0;
  Attr[] array=new Attr[len];
  for (int i=0; i < len; i++) {
    array[i]=(Attr)attrs.item(i);
  }
  for (int i=0; i < len - 1; i++) {
    String name=array[i].getNodeName();
    int index=i;
    for (int j=i + 1; j < len; j++) {
      String curName=array[j].getNodeName();
      if (curName.compareTo(name) < 0) {
        name=curName;
        index=j;
      }
    }
    if (index != i) {
      Attr temp=array[i];
      array[i]=array[index];
      array[index]=temp;
    }
  }
  return (array);
}
 

Example 67

From project lastfm-android, under directory /library/src/fm/last/util/.

Source file: XMLUtil.java

  29 
vote

static String getNamedItemNodeValue(NamedNodeMap attributes,String name,String defvalue){
  if (attributes == null) {
    return null;
  }
  Node namenode=attributes.getNamedItem(name);
  if (namenode == null)   return defvalue;
  if (namenode.getNodeValue() == null)   return defvalue;
  return namenode.getNodeValue();
}
 

Example 68

From project litle-sdk-for-java, under directory /lib/xerces-2_11_0/samples/dom/.

Source file: DOMAddLines.java

  29 
vote

/** 
 * Returns a sorted list of attributes. 
 */
private Attr[] sortAttributes(NamedNodeMap attrs){
  int len=(attrs != null) ? attrs.getLength() : 0;
  Attr array[]=new Attr[len];
  for (int i=0; i < len; i++) {
    array[i]=(Attr)attrs.item(i);
  }
  for (int i=0; i < len - 1; i++) {
    String name=array[i].getNodeName();
    int index=i;
    for (int j=i + 1; j < len; j++) {
      String curName=array[j].getNodeName();
      if (curName.compareTo(name) < 0) {
        name=curName;
        index=j;
      }
    }
    if (index != i) {
      Attr temp=array[i];
      array[i]=array[index];
      array[index]=temp;
    }
  }
  return (array);
}