Package org.exist.dom

Examples of org.exist.dom.QName


    }

    @Override
    public boolean match(NodePath other) {
        if (isQNameIndex) {
            final QName qn1 = path.getLastComponent();
            final QName qn2 = other.getLastComponent();
            return qn1.getNameType() == qn2.getNameType() && qn2.equalsSimple(qn1);
        }
        return path.match(other);
    }
View Full Code Here


                    StandardDiff.NAMESPACE.equals(reader.getNamespaceURI())) {
                if (status == XMLStreamReader.START_ELEMENT) {
                    if ("attribute".equals(reader.getLocalName())) {
                        int attrCount = reader.getAttributeCount();
                        for (int i = 0; i < attrCount; i++) {
                            QName qname = reader.getAttributeQName(i);
                            receiver.attribute(qname, reader.getAttributeValue(i));
                        }
                    } else if ("comment".equals(reader.getLocalName())) {
                        StringBuffer buf = new StringBuffer();
                        while (reader.hasNext()) {
                            status = reader.next();
                            if (status == XMLStreamReader.END_ELEMENT &&
                                    reader.getNamespaceURI().equals(StandardDiff.NAMESPACE) &&
                                    reader.getLocalName().equals("comment"))
                                break;
                            if (status == XMLStreamReader.CHARACTERS)
                                buf.append(reader.getText());
                        }
                        char[] ch = buf.toString().toCharArray();
                        receiver.comment(ch, 0, ch.length);
                    } else if ("start".equals(reader.getLocalName())) {
                        String namespace = reader.getAttributeValue("", "namespace");
                        String name = reader.getAttributeValue("", "name");
                        receiver.startElement(new QName(QName.extractLocalName(name), namespace, QName.extractPrefix(name)), null);
                        if (annotate)
                            receiver.attribute(ATTR_CHANGE, "tag-" + changeMessage);
                    } else if ("end".equals(reader.getLocalName())) {
                        String namespace = reader.getAttributeValue("", "namespace");
                        String name = reader.getAttributeValue("", "name");
                        receiver.endElement(new QName(QName.extractLocalName(name), namespace, QName.extractPrefix(name)));
                    }
                }
            } else {
                copyNode(reader, receiver, status, treeLevel == 0, changeMessage);
                if (status == XMLStreamReader.START_ELEMENT)
View Full Code Here

                Expression outerExpr = contextInfo.getContextStep();
                if (outerExpr != null && outerExpr instanceof LocationStep) {
                    LocationStep outerStep = (LocationStep) outerExpr;
                    NodeTest test = outerStep.getTest();
                    if (test.getName() == null)
                        contextQName = new QName(null, null, null);
                    else if (test.isWildcardTest())
                        contextQName = test.getName();
                    else
                        contextQName = new QName(test.getName());
                    if (outerStep.getAxis() == Constants.ATTRIBUTE_AXIS || outerStep.getAxis() == Constants.DESCENDANT_ATTRIBUTE_AXIS)
                        contextQName.setNameType(ElementValue.ATTRIBUTE);
                    contextStep = firstStep;
                    axis = outerStep.getAxis();
                    optimizeSelf = true;
                }
            } else if (lastStep != null && firstStep != null) {
                NodeTest test = lastStep.getTest();
                if (test.getName() == null)
                    contextQName = new QName(null, null, null);
                else if (test.isWildcardTest())
                    contextQName = test.getName();
                else
                    contextQName = new QName(test.getName());
                if (lastStep.getAxis() == Constants.ATTRIBUTE_AXIS || lastStep.getAxis() == Constants.DESCENDANT_ATTRIBUTE_AXIS)
                    contextQName.setNameType(ElementValue.ATTRIBUTE);
                axis = firstStep.getAxis();
                optimizeChild = steps.size() == 1 &&
                    (axis == Constants.CHILD_AXIS || axis == Constants.ATTRIBUTE_AXIS);
View Full Code Here

                            child = (StoredNode) child.getNextSibling();
                        }
                    }

                    if (deletedNodes.get(nodeId) == null) {
                        QName attrQn = new QName(reader.getAttributeLocalName(i), reader.getAttributeNamespace(i),
                                reader.getAttributePrefix(i));
                        attrs.addAttribute(
                                attrQn,
                                reader.getAttributeValue(i),
                                getAttributeType(reader.getAttributeType(i))
                        );
                    }
                }
                QName qn = new QName(reader.getLocalName(), reader.getNamespaceURI(), reader.getPrefix());
                receiver.startElement(qn, attrs);
                if (elementStack != null)
                    elementStack.push(qn);
                break;
            case XMLStreamReader.END_ELEMENT:
                receiver.endElement(new QName(reader.getLocalName(), reader.getNamespaceURI(), reader.getPrefix()));
                if (elementStack != null) {
                    if (elementStack.isEmpty())
                        receiver.endPrefixMapping(StandardDiff.PREFIX);
                    elementStack.pop();
                }
View Full Code Here

      boolean includeHeaders = args[1].effectiveBooleanValue();
     
      MemTreeBuilder builder = context.getDocumentBuilder();
       
          builder.startDocument();
          builder.startElement( new QName( "messages", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
          builder.addAttribute( new QName( "count", null, null ), String.valueOf( msgList.length ) );
     
      try {
        for( int i = 0; i < msgList.length; i++ ) {
          Message message = msgList[ i ];
         
          builder.startElement( new QName( "message", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );

          builder.addAttribute( new QName( "number", null, null ), String.valueOf(message.getMessageNumber()) );
         
          // Sent Date
          if( message.getSentDate() != null ) {
            builder.startElement( new QName( "sent", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
            builder.characters( formatDate( message.getSentDate() ) );
            builder.endElement();
              }
         
          // Received Date
          if( message.getReceivedDate() != null ) {
            builder.startElement( new QName( "received", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
            builder.characters( formatDate( message.getReceivedDate() ) );
            builder.endElement();
              }
         
          // From
          if( message.getFrom() != null ) {
            builder.startElement( new QName( "from", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
            builder.characters( message.getFrom()[0].toString() );
            builder.endElement();
          }
         
          // Recipients
          builder.startElement( new QName( "recipients", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
            // To Recipients
            Address[] toAddresses = message.getRecipients( Message.RecipientType.TO );
            if( toAddresses != null ) {
                        for (Address to : toAddresses) {
                            builder.startElement( new QName( "recipient", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                            builder.addAttribute( new QName( "type", null, null ), "to" );
                            builder.characters(to.toString());
                            builder.endElement();
                        }
            }
           
            // cc Recipients
            Address[] ccAddresses = message.getRecipients( Message.RecipientType.CC );
            if( ccAddresses != null ) {
                        for (Address ccAddress : ccAddresses) {
                            builder.startElement( new QName( "recipient", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                            builder.addAttribute( new QName( "type", null, null ), "cc" );
                            builder.characters(ccAddress.toString());
                            builder.endElement();
                        }
            }
           
            // bcc Recipients
            Address[] bccAddresses = message.getRecipients( Message.RecipientType.BCC );
            if( bccAddresses != null ) {
                        for (Address bccAddress : bccAddresses) {
                            builder.startElement( new QName( "recipient", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                            builder.addAttribute( new QName( "type", null, null ), "bcc" );
                            builder.characters(bccAddress.toString());
                            builder.endElement();
                        }
            }
          builder.endElement();
         
          // Flags
         
          Flags       flags   = message.getFlags();
          Flags.Flag[]   systemFlags    = flags.getSystemFlags();
          String[]     userFlags     = flags.getUserFlags();
         
          if( systemFlags.length > 0 || userFlags.length > 0 ) {
            builder.startElement( new QName( "flags", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
           
                        for (Flags.Flag systemFlag : systemFlags) {
                            if (systemFlag == Flags.Flag.ANSWERED) {
                                builder.startElement( new QName( "flag", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                                builder.addAttribute( new QName( "type", null, null ), "answered" );
                                builder.endElement();
                            } else if (systemFlag == Flags.Flag.DELETED) {
                                builder.startElement( new QName( "flag", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                                builder.addAttribute( new QName( "type", null, null ), "deleted" );
                                builder.endElement();
                            } else if (systemFlag == Flags.Flag.DRAFT) {
                                builder.startElement( new QName( "flag", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                                builder.addAttribute( new QName( "type", null, null ), "draft" );
                                builder.endElement();
                            } else if (systemFlag == Flags.Flag.FLAGGED) {
                                builder.startElement( new QName( "flag", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                                builder.addAttribute( new QName( "type", null, null ), "flagged" );
                                builder.endElement();
                            } else if (systemFlag == Flags.Flag.RECENT) {
                                builder.startElement( new QName( "flag", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                                builder.addAttribute( new QName( "type", null, null ), "recent" );
                                builder.endElement();
                            } else if (systemFlag == Flags.Flag.SEEN) {
                                builder.startElement( new QName( "flag", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                                builder.addAttribute( new QName( "type", null, null ), "seen" );
                                builder.endElement();
                            }
                        }
           
                        for (String userFlag : userFlags) {
                            builder.startElement( new QName( "flag", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                            builder.addAttribute( new QName( "type", null, null ), "user" );
                            builder.addAttribute(new QName( "value", null, null ), userFlag);
                            builder.endElement();
                        }

            builder.endElement();
          }

          // Headers
         
          if( includeHeaders ) {
            Enumeration headers = message.getAllHeaders();
           
            if( headers.hasMoreElements() ) {
              builder.startElement( new QName( "headers", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
             
              while( headers.hasMoreElements() ) {
                Header header = (Header)headers.nextElement();
               
                builder.startElement( new QName( "header", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
                      builder.addAttribute( new QName( "name", null, null ), header.getName() );
                builder.addAttribute( new QName( "value", null, null ), header.getValue() );
                builder.endElement();
              }
             
              builder.endElement();
            }
          }
         
          // Subject
          builder.startElement( new QName( "subject", MailModule.NAMESPACE_URI, MailModule.PREFIX ), null );
          builder.characters( message.getSubject() );
          builder.endElement();
         
          builder.endElement();
        }
View Full Code Here

    }

    protected final static class LuceneErrorCode extends ErrorCode {

    public LuceneErrorCode(String code, String description) {
      super(new QName(code, NAMESPACE_URI, PREFIX), description);
    }
View Full Code Here

        File home = context.getBroker().getConfiguration().getExistHome();
        targetDir = new File(home, target);
      }
     
      output.startDocument();
      output.startElement(new QName("sync", FileModule.NAMESPACE_URI), null);
      output.addAttribute(new QName("collection", FileModule.NAMESPACE_URI), collectionPath);
      output.addAttribute(new QName("dir", FileModule.NAMESPACE_URI), targetDir.getAbsolutePath());
     
      saveCollection(XmldbURI.create(collectionPath), targetDir, startDate, output);
     
      output.endElement();
      output.endDocument();
View Full Code Here

      saveCollection(collectionPath.append(childURI), childDir, startDate, output);
    }
  }

  private void reportError(MemTreeBuilder output, String msg) {
    output.startElement(new QName("error", FileModule.NAMESPACE_URI), null);
    output.characters(msg);
    output.endElement();
  }
View Full Code Here

      return;
    }
        boolean isRepoXML = targetFile.exists() && targetFile.getName().equals("repo.xml");
    SAXSerializer sax = (SAXSerializer)SerializerPool.getInstance().borrowObject( SAXSerializer.class );
    try {
      output.startElement(new QName("update", FileModule.NAMESPACE_URI), null);
      output.addAttribute(new QName("file"), targetFile.getAbsolutePath());
      output.addAttribute(new QName("name"), doc.getFileURI().toString());
      output.addAttribute(new QName("collection"), doc.getCollection().getURI().toString());
      output.addAttribute(new QName("type"), "xml");
      output.addAttribute(new QName("modified"), new DateTimeValue(new Date(doc.getMetadata().getLastModified())).getStringValue());
            if (isRepoXML) {
                processRepoDesc(targetFile, doc, sax, output);
            } else {
                OutputStream os = new FileOutputStream(targetFile);
                            try (Writer writer = new OutputStreamWriter(os, "UTF-8")) {
View Full Code Here

    File targetFile = new File(targetDir, binary.getFileURI().toASCIIString());
    if (targetFile.exists() && targetFile.lastModified() >= binary.getMetadata().getLastModified()) {
      return;
    }
    try {
      output.startElement(new QName("update", FileModule.NAMESPACE_URI), null);
      output.addAttribute(new QName("file"), targetFile.getAbsolutePath());
      output.addAttribute(new QName("name"), binary.getFileURI().toString());
      output.addAttribute(new QName("collection"), binary.getCollection().getURI().toString());
      output.addAttribute(new QName("type"), "binary");
      output.addAttribute(new QName("modified"),
          new DateTimeValue(new Date(binary.getMetadata().getLastModified())).getStringValue());
     
                        InputStream is;
                    try (OutputStream os = new FileOutputStream(targetFile)) {
                        is = context.getBroker().getBinaryResource(binary);
View Full Code Here

TOP

Related Classes of org.exist.dom.QName

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.