Package org.exist.xquery.value

Examples of org.exist.xquery.value.StringValue


          while (tok.hasMoreTokens()) {
                    buf.append(tok.nextToken());
            if (tok.hasMoreTokens()) {buf.append(' ');}
          }
        }
            result = new StringValue(buf.toString());
        }
       
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
       
View Full Code Here


      if(gotOne && sep != null)
        {out.append(sep);}
      out.append(next.getStringValue());
      gotOne = true;
    }
    final Sequence result = new StringValue(out.toString());
       
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
       
        return result;
View Full Code Here

            String newNormalizationForm = "NFC";
      if (getArgumentCount() > 1)
        {newNormalizationForm = getArgument(1).eval(contextSequence).getStringValue().toUpperCase().trim();}
      //TODO : handle the "FULLY-NORMALIZED" string...
      if ("".equals(newNormalizationForm))
        {result =  new StringValue(s1.getStringValue());}
      else {
        Object returnedObject = null;
        try {
              if (clazz == null)
                {clazz = Class.forName("com.ibm.icu.text.Normalizer");}
              if (modeField == null || !normalizationForm.equals(newNormalizationForm)) {
                try {
                  modeField = clazz.getField(newNormalizationForm);
                } catch (final NoSuchFieldException e) {
                            logger.error("err:FOCH0003: unknown normalization form");
                  throw new XPathException(this, ErrorCodes.FOCH0003, "unknown normalization form");
                }
                  //com.ibm.icu.text.Normalizer.Mode
                  modeObject = modeField.get(null);
                normalizationForm = newNormalizationForm;
              }
              if (constructor == null)
                //Second argument shouldn't be a problem : modeField always has the same type
                  {constructor = clazz.getConstructor(
                      new Class[] { String.class, modeField.getType(), Integer.TYPE}
                    );}
              final Object[] args = new Object[] { s1.getStringValue(), modeObject, DUMMY_INTEGER };
              if (method == null)
                {method = clazz.getMethod( "getText", (Class[])null );}
 
              //Normalizer n = new Normalizer(s1.getStringValue(), Normalizer.NFC, 0);
              final Object instance = constructor.newInstance(args);
              //result = new StringValue(n.getText());
              returnedObject = method.invoke( instance, (Object[])null );
            } catch (final Exception e) {
                    logger.error("Can not find the ICU4J library in the classpath " + e.getMessage());
              throw new XPathException(this, "Can not find the ICU4J library in the classpath " + e.getMessage());
            }
            result = new StringValue((String)returnedObject);
      }
        }
       
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
View Full Code Here

    this.mimeType=MimeType.XML_TYPE.getName();
    }

    public Object getContent() throws XMLDBException {
        if (content != null) {
            return new StringValue(content).getStringValue(true);
        }
        final Object res=super.getContent();
        if(res!=null) {
    if(res instanceof byte[]) {
            return new String((byte[])res, UTF_8);
View Full Code Here

            final Sequence result = new ValueSequence();

            final Map<String, String> env = context.getEnvironmentVariables();
            for (final String key : env.keySet()) {
                result.add(new StringValue(key));
            }

            return result;

        } else {

            if (args[0].isEmpty()) {
                return Sequence.EMPTY_SEQUENCE;
            }

            final String parameter = args[0].itemAt(0).getStringValue();

            final String value = context.getEnvironmentVariables().get(parameter);
            if (value == null) {
                return Sequence.EMPTY_SEQUENCE;
            }

            return new StringValue(value);
        }
    }
View Full Code Here

   */
  private StringValue substring(String sourceString, NumericValue startingLoc)
        throws XPathException {
    if(startingLoc.getInt() <= 1) {
      //start value is 1 or less, so just return the string
      return new StringValue(sourceString);
    }
        final ValueSequence codepoints = FunStringToCodepoints.getCodePoints(sourceString);
        // transition from xs:string index to Java string index.
        return new StringValue(FunStringToCodepoints.subSequence(codepoints, startingLoc.getInt() - 1));
   }
View Full Code Here

   */
  private StringValue substring(String sourceString, NumericValue startingLoc, NumericValue endingLoc)
        throws XPathException {
        final ValueSequence codepoints = FunStringToCodepoints.getCodePoints(sourceString);
        // transition from xs:string index to Java string index.
        return new StringValue(FunStringToCodepoints.subSequence(codepoints,
                                                                 startingLoc.getInt() - 1,
                                                                 endingLoc.getInt() - 1));
  }
View Full Code Here

                "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

    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());}
        }

        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}       
       
View Full Code Here

        else {
            if (!Type.subTypeOf(item.getType(), Type.NODE))
              {throw new XPathException(this, ErrorCodes.XPTY0004, "item is not a node; got '" + Type.getTypeName(item.getType()) + "'");}         
            //TODO : how to improve performance ?
            final Node n = ((NodeValue)item).getNode();
            result = new StringValue(n.getLocalName());
        }
       
        if (context.getProfiler().isEnabled())
            {context.getProfiler().end(this, "", result);}
       
View Full Code Here

TOP

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

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.