Package org.exist.xquery.value

Examples of org.exist.xquery.value.Sequence


                "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));
            if (contextSequence != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES,
                    "CONTEXT SEQUENCE", contextSequence);}
        }
        final Sequence result = new StringValue(context.getDefaultCollation());
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
        return result;
       
    }
View Full Code Here


                {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);}
            if (contextItem != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT ITEM", contextItem.toSequence());}
        }       
       
        Sequence result;
        Sequence seq = getArgument(0).eval(contextSequence, contextItem);
    if (seq.isEmpty())
            {result = Sequence.EMPTY_SEQUENCE;}
        else {           
            //TODO : explain this Double conversion -pb
        int pos = ((DoubleValue)getArgument(1).eval(contextSequence, contextItem).convertTo(Type.DOUBLE)).getInt();
        if (pos < 1 || pos > seq.getItemCount())
                {result= seq;}
            else {
            pos--;
            if (seq instanceof NodeSet) {
              result = new ExtArrayNodeSet();
              result.addAll((NodeSet) seq);
              result = ((NodeSet)result).except((NodeSet) seq.itemAt(pos));
            } else {
              result = new ValueSequence();
              for (int i = 0; i < seq.getItemCount(); i++) {
                if (i != pos) {result.add(seq.itemAt(i));}
              }             
            }
            }
        }
       
View Full Code Here

                    "CONTEXT SEQUENCE", contextSequence);}
            if (contextItem != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES,
                    "CONTEXT ITEM", contextItem.toSequence());}
        }
        final Sequence seq1 = getArgument(0).eval(contextSequence, contextItem);
        final Sequence seq2 =  getArgument(1).eval(contextSequence, contextItem);
        Sequence result;
        if (seq1.isEmpty() || seq2.isEmpty()) {
            result = Sequence.EMPTY_SEQUENCE;
        } else {
            final Collator collator = getCollator(contextSequence, contextItem, 3);   
            final int comparison = Collations.compare(collator, seq1.getStringValue(), seq2.getStringValue());
View Full Code Here

                }
            }

            DebuggeeFactory.checkForDebugRequest(request, context);

            Sequence resultSequence;
            try {
                resultSequence = xquery.execute(query, null, outputProperties);
               
            } finally {
                context.runCleanupTasks();
                xquery.getXQueryPool().returnCompiledXQuery(source, query);
            }

            final String mediaType = outputProperties.getProperty(OutputKeys.MEDIA_TYPE);
            if (mediaType != null) {
                if (!response.isCommitted())
                  {if (MimeTable.getInstance().isTextContent(mediaType)) {
                    response.setContentType(mediaType + "; charset=" + getFormEncoding());
                        response.setCharacterEncoding(getFormEncoding());
                    } else
                    response.setContentType(mediaType);}
               
            } else {
              String contentType = this.contentType;
              try {
                  contentType = getServletContext().getMimeType(path);
                  if (contentType == null)
                      {contentType = this.contentType;}
                   
              } catch (final Throwable e) {
                  contentType = this.contentType;
                   
              } finally {
                  if (MimeTable.getInstance().isTextContent(contentType))
                      {contentType += "; charset=" + getFormEncoding();}
                  response.setContentType(contentType );
              }
            }
           
            if (requestAttr != null && (XmldbURI.API_LOCAL.equals(collectionURI.getApiName())) ) {
                request.setAttribute(requestAttr, resultSequence);
               
            } else {
              final Serializer serializer = broker.getSerializer();
              serializer.reset();
           
              final SerializerPool serializerPool = SerializerPool.getInstance();

              final SAXSerializer sax = (SAXSerializer) serializerPool.borrowObject(SAXSerializer.class);
              try {
                sax.setOutput(output, outputProperties);
                serializer.setProperties(outputProperties);
                serializer.setSAXHandlers(sax, sax);
                serializer.toSAX(resultSequence, 1, resultSequence.getItemCount(), false, false);
                   
              } finally {
                serializerPool.returnObject(sax);
              }
            }
View Full Code Here

            {contextSequence = getArgument(1).eval(contextSequence);}
   
    if (contextSequence == null)
      {throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");}
   
        Sequence result;
    if (!(Type.subTypeOf(contextSequence.getItemType(), Type.NODE)))
      {throw new XPathException(this, ErrorCodes.XPTY0004, "Context item is not a node");}
        else {
      final String lang = getArgument(0).eval(contextSequence).getStringValue();
     
      String langValue = null;
      Sequence seq = null;
      if (contextSequence.hasOne()) {
        final Item item = contextSequence.itemAt(0);
        if (item.getType() == Type.ATTRIBUTE) {
          langValue = item.getStringValue();
        }
      } else {
        seq = query.eval(contextSequence);
      }
     
      if (seq != null && seq.isEmpty()) {
        result = BooleanValue.FALSE ;  
      } else if (langValue != null || (seq != null && seq.hasOne())) {
        if (seq != null)
          {langValue = seq.getStringValue();}
             
        boolean include = lang.equalsIgnoreCase(langValue);
        if (!include) {
                  final int hyphen = langValue.indexOf('-');
          if (hyphen != Constants.STRING_NOT_FOUND) {
View Full Code Here

        }
       
    if(contextItem != null)
      {contextSequence = contextItem.toSequence();}
       
        Sequence result;
    final Sequence seq = getArgument(0).eval(contextSequence);
    if (seq.isEmpty())
            {result = StringValue.EMPTY_STRING;}
        else {
        final String value = seq.getStringValue();
        if(isCalledAs("upper-case"))
                {result = new StringValue(value.toUpperCase());}
        else
                {result = new StringValue(value.toLowerCase());}
        }
View Full Code Here

            if (contextItem != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES,
                        "CONTEXT ITEM", contextItem.toSequence());}
        }
       
        Sequence result;
       
    final Sequence inner = getArgument(0).eval(contextSequence, contextItem)
    if (inner.isEmpty()) {
      //If $zero is not specified, then the value returned for an empty sequence is the xs:integer value 0
      Sequence zero = IntegerValue.ZERO;
      if(getSignature().getArgumentCount() == 2)
        {zero = getArgument(1).eval(contextSequence, contextItem);}
      result = zero;
    } else {
        final SequenceIterator iter = inner.iterate();
View Full Code Here

        }
       
        Item item = null;
        // check if the node is passed as an argument or should be taken from the context sequence
        if(getArgumentCount() > 0) {
            final Sequence seq = getArgument(0).eval(contextSequence, contextItem);
            if(!seq.isEmpty())
                {item = seq.itemAt(0);}
        } else {
          if (contextItem == null)
              {throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");}
          item = contextItem;
        }
       
        Sequence result;
        if(item == null)
            {result = AnyURIValue.EMPTY_URI;}
        else {         
            if(!Type.subTypeOf(item.getType(), Type.NODE))
                {throw new XPathException(this, ErrorCodes.XPTY0004, "Context item is not a node; got: " +
View Full Code Here

               
        Item item = null;
        // check if the node is passed as an argument or should be taken from
        // the context sequence
        if(getArgumentCount() > 0) {
            final Sequence seq = getArgument(0).eval(contextSequence);
            if (!seq.isEmpty())
                {item = seq.itemAt(0);}
        } else {
          if (contextSequence == null || contextSequence.isEmpty())
            {throw new XPathException(this, ErrorCodes.XPDY0002, "Undefined context item");}
            item = contextSequence.itemAt(0);
        }
       
        Sequence result;
        if (item == null)
            {result = StringValue.EMPTY_STRING;}
        else {
            if (!Type.subTypeOf(item.getType(), Type.NODE))
              {throw new XPathException(this, ErrorCodes.XPTY0004, "item is not a node; got '" + Type.getTypeName(item.getType()) + "'");}         
View Full Code Here

            context.getProfiler().message(this, Profiler.DEPENDENCIES, "DEPENDENCIES", Dependency.getDependenciesName(this.getDependencies()));
            if (contextSequence != null)
                {context.getProfiler().message(this, Profiler.START_SEQUENCES, "CONTEXT SEQUENCE", contextSequence);}
        }
       
        Sequence result;
        if (isCalledAs("true"))
            {result = BooleanValue.TRUE;}
    else
            {result = BooleanValue.FALSE;}       
       
View Full Code Here

TOP

Related Classes of org.exist.xquery.value.Sequence

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.