Converts a primitive data object into a primitive expression node.

@param primitiveData The primitive data object to convert. Must not be undefined.
@param location The node's source location.
@return The resulting primitive expression node.
9259
@Nullable
  public static PrimitiveNode convertPrimitiveDataToExpr(
      PrimitiveData primitiveData, SourceLocation location) {
    if (primitiveData instanceof StringData) {
      return new StringNode(primitiveData.stringValue(), QuoteStyle.SINGLE, location);
    } else if (primitiveData instanceof BooleanData) {
      return new BooleanNode(primitiveData.booleanValue(), location);
    } else if (primitiveData instanceof IntegerData) {
      // NOTE: We only support numbers in the range of JS [MIN_SAFE_INTEGER, MAX_SAFE_INTEGER]
      if (!IntegerNode.isInRange(primitiveData.longValue())) {
        return null;
      } else {
        return new IntegerNode(primitiveData.longValue(), location);
      }
    } else if (primitiveData instanceof FloatData) {
      return new FloatNode(primitiveData.floatValue(), location);
    } else if (primitiveData instanceof NullData) {
      return new NullNode(location);
    } else {
      throw new IllegalArgumentException();
    }
  }
709861
public static TypeAnnotationPosition
        methodThrows(final List<TypePathEntry> location,
                     final JCLambda onLambda,
                     final int type_index,
                     final int pos) {
        return new TypeAnnotationPosition(TargetType.THROWS, pos,
                                          Integer.MIN_VALUE, onLambda,
                                          type_index, Integer.MIN_VALUE,
                                          location);
    }
490247
public static XSLTTransformationFileSystem usingFilesystem(String location)
    {
        XSLTTransformation tansformation = new XSLTTransformation();
        tansformation.template = location;
        return tansformation;
    }
1366770
public static DataNode createFromEncoded(String encodedData, String baseUri) {
        String data = Entities.unescape(encodedData);
        return new DataNode(data);
    }
829240
public Object visit(QueryRootNode node, Object data) throws RepositoryException {
        StringBuilder sb = (StringBuilder) data;
        try {
            sb.append("SELECT");

            InternalQName[] selectProps = node.getSelectProperties();
            if (selectProps.length == 0) {
                sb.append(" *");
            } else {
                String comma = "";
                for (int i = 0; i < selectProps.length; i++) {
                    sb.append(comma).append(" ");
                    appendName(selectProps[i], resolver, sb);
                    comma = ",";
                }
            }

            sb.append(" FROM");

            // node type restrictions are within predicates of location nodes
            // therefore we write the where clause first to a temp string to
            // collect the node types.
            StringBuilder tmp = new StringBuilder();
            LocationStepQueryNode[] steps = node.getLocationNode().getPathSteps();
            QueryNode[] predicates = steps[steps.length - 1].getPredicates();
            // are there any relevant predicates?
            for (int i = 0; i < predicates.length; i++) {
                if (predicates[i].getType() != QueryNode.TYPE_NODETYPE) {
                    tmp.append(" WHERE ");
                }
            }
            String and = "";
            for (int i = 0; i < predicates.length; i++) {
                if (predicates[i].getType() != QueryNode.TYPE_NODETYPE) {
                    tmp.append(and);
                    and = " AND ";
                }
                predicates[i].accept(this, tmp);
            }

            // node types have been collected by now
            String comma = "";
            int ntCount = 0;
            for (Iterator<InternalQName> it = nodeTypes.iterator(); it.hasNext(); ntCount++) {
               InternalQName nt = it.next();
                sb.append(comma).append(" ");
                appendName(nt, resolver, sb);
                comma = ",";
            }

            if (ntCount == 0) {
                sb.append(" ");
                sb.append(resolver.createJCRName(Constants.NT_BASE).getAsString());
            }

            // append WHERE clause
            sb.append(tmp.toString());

            if (steps.length == 2
                    && steps[1].getIncludeDescendants()
                    && steps[1].getNameTest() == null) {
                // then this query selects all paths
            } else if (steps.length == 1
                    && steps[0].getIncludeDescendants()
                    && steps[0].getNameTest() == null) {
                // then this query selects all paths
            } else {
                if (predicates.length > 0) {
                    sb.append(" AND ");
                } else {
                    sb.append(" WHERE ");
                }
                node.getLocationNode().accept(this, sb);
            }
        } catch (NamespaceException e) {
            exceptions.add(e);
        }

        if (node.getOrderNode() != null) {
            node.getOrderNode().accept(this, sb);
        }

        return sb;
    }
272952
public Location parse(String locationString) throws ParserException {
		featureGlobalStart = Integer.MAX_VALUE;
		featureGlobalEnd = 1;

		Location l;
		List<Location> ll = parseLocationString(locationString, 1);

		if (ll.size() == 1) {
			l = ll.get(0);
		} else {
			l = new SimpleLocation(
					featureGlobalStart,
					featureGlobalEnd,
					Strand.UNDEFINED,
					ll);
		}
		return l;
	}
1282738
protected FieldMetadata processPrimitiveType( FieldDeclaration fieldDeclaration ) {
        PrimitiveType primitiveType = (PrimitiveType)fieldDeclaration.getType();
        FieldMetadata primitiveFieldMetadata = FieldMetadata.primitiveType(primitiveType.getPrimitiveTypeCode().toString());
        primitiveFieldMetadata.setName(getFieldName(fieldDeclaration));

        // modifiers
        processModifiersOfFieldDeclaration(fieldDeclaration, primitiveFieldMetadata);
        // variables
        processVariablesOfVariableDeclarationFragment(fieldDeclaration, primitiveFieldMetadata);
        return primitiveFieldMetadata;
    }
72314
public static DataExpr parseDataExpr(String expr) {
    try {
      return (DataExpr) parse(expr);
    } catch (ClassCastException e) {
      throw new IllegalArgumentException("invalid data expression: " + expr, e);
    }
  }
1265066
@Override
    public void onID(Datatype datatype, StringToken idToken)
        throws IllegalArgumentException
    {
        if (mIdDefs == null) {
            mIdDefs = new ElementIdMap();
        }

        int idType = datatype.getIdType();
        Location loc = mContext.getValidationLocation();
        PrefixedName elemPName = getElementPName();
        PrefixedName attrPName = getAttrPName();

        if (idType == Datatype.ID_TYPE_ID) {
            String idStr = idToken.literal.trim();
            ElementId eid = mIdDefs.addDefined(idStr, loc, elemPName, attrPName);
            // We can detect dups by checking if Location is the one we passed:
            if (eid.getLocation() != loc) {
                mProblem = new XMLValidationProblem(loc, "Duplicate id '"+idStr+"', first declared at "+eid.getLocation());
                mProblem.setReporter(this);
            }
        } else if (idType == Datatype.ID_TYPE_IDREF) {
            String idStr = idToken.literal.trim();
            mIdDefs.addReferenced(idStr, loc, elemPName, attrPName);
        } else if (idType == Datatype.ID_TYPE_IDREFS) {
            StringTokenizer tokens = new StringTokenizer(idToken.literal);
            while (tokens.hasMoreTokens()) {
                mIdDefs.addReferenced(tokens.nextToken(), loc, elemPName, attrPName);
            }
        } else { // sanity check
            throw new IllegalStateException("Internal error: unexpected ID datatype: "+datatype);
        }
    }
179498
public static ProtoFileElement parse(Location location, String data) {
    return new ProtoParser(location, data.toCharArray()).readProtoFile();
  }
418651
public static TypeAnnotationPosition
        methodReturn(final List<TypePathEntry> location,
                     final JCLambda onLambda,
                     final int pos) {
        return new TypeAnnotationPosition(TargetType.METHOD_RETURN, pos,
                                          Integer.MIN_VALUE, onLambda,
                                          Integer.MIN_VALUE, Integer.MIN_VALUE,
                                          location);
    }
426853
protected Expression string(Data data) throws TemplateException {

	// check starting character for a string literal
	if (!data.srcCode.isCurrent('"') && !data.srcCode.isCurrent('\'')) return null;
	Position line = data.srcCode.getPosition();

	// Init Parameter
	char quoter = data.srcCode.getCurrentLower();
	StringBuilder str = new StringBuilder();
	Expression expr = null;

	while (data.srcCode.hasNext()) {
	    data.srcCode.next();
	    // check sharp
	    if (data.srcCode.isCurrent('#')) {

		// Ecaped sharp
		if (data.srcCode.isNext('#')) {
		    data.srcCode.next();
		    str.append('#');
		}
		// get Content of sharp
		else {
		    data.srcCode.next();
		    comments(data);
		    Expression inner = assignOp(data);
		    comments(data);
		    if (!data.srcCode.isCurrent('#')) throw new TemplateException(data.srcCode, "Invalid Syntax Closing [#] not found");

		    ExprString exprStr = null;
		    if (str.length() != 0) {
			exprStr = data.factory.createLitString(str.toString(), line, data.srcCode.getPosition());
			if (expr != null) {
			    expr = data.factory.opString(expr, exprStr);
			}
			else expr = exprStr;
			str = new StringBuilder();
		    }
		    if (expr == null) {
			expr = inner;
		    }
		    else {
			expr = data.factory.opString(expr, inner);
		    }
		}
	    }
	    // check quoter
	    else if (data.srcCode.isCurrent(quoter)) {
		// Ecaped sharp
		if (data.srcCode.isNext(quoter)) {
		    data.srcCode.next();
		    str.append(quoter);
		}
		// finsish
		else {
		    break;
		}
	    }
	    // all other character
	    else {
		str.append(data.srcCode.getCurrent());
	    }
	}
	if (!data.srcCode.forwardIfCurrent(quoter)) throw new TemplateException(data.srcCode, "Invalid Syntax Closing [" + quoter + "] not found");

	if (expr == null) expr = data.factory.createLitString(str.toString(), line, data.srcCode.getPosition());
	else if (str.length() != 0) {
	    expr = data.factory.opString(expr, data.factory.createLitString(str.toString(), line, data.srcCode.getPosition()));
	}
	comments(data);

	if (expr instanceof Variable) {
	    Variable var = (Variable) expr;
	    var.fromHash(true);
	}

	return expr;

    }
594109
@Override
  protected Expression visitFunctionNode(FunctionNode node) {
    Object soyFunction = node.getSoyFunction();

    if (soyFunction instanceof BuiltinFunction) {
      switch ((BuiltinFunction) soyFunction) {
        case IS_FIRST:
          return visitIsFirstFunction(node);
        case IS_LAST:
          return visitIsLastFunction(node);
        case INDEX:
          return visitIndexFunction(node);
        case CHECK_NOT_NULL:
          return visitCheckNotNullFunction(node);
        case CSS:
          return visitCssFunction(node);
        case XID:
          return visitXidFunction(node);
        case V1_EXPRESSION:
          return visitV1ExpressionFunction(node);
        case IS_PRIMARY_MSG_IN_USE:
          return visitIsPrimaryMsgInUseFunction(node);
        case TO_FLOAT:
          // this is a no-op in js
          return visit(node.getChild(0));
        case DEBUG_SOY_TEMPLATE_INFO:
          return GOOG_DEBUG.and(JsRuntime.SOY_DEBUG_SOY_TEMPLATE_INFO, codeGenerator);
        case VE_DATA:
          return visitVeDataFunction(node);
        case REMAINDER:
        case MSG_WITH_ID:
          // should have been removed earlier in the compiler
          throw new AssertionError();
      }
      throw new AssertionError();

    } else if (soyFunction instanceof LoggingFunction) {
      return stringLiteral(((LoggingFunction) soyFunction).getPlaceholder());
    } else if (soyFunction instanceof SoyJavaScriptSourceFunction) {
      return javascriptValueFactory.applyFunction(
          node.getSourceLocation(),
          node.getFunctionName(),
          (SoyJavaScriptSourceFunction) soyFunction,
          visitChildren(node),
          codeGenerator);
    } else {
      if (!(soyFunction instanceof SoyJsSrcFunction)) {
        errorReporter.report(
            node.getSourceLocation(),
            SOY_JS_SRC_FUNCTION_NOT_FOUND,
            node.getFunctionName(),
            soyFunction == null ? "missing implementation" : soyFunction.getClass().getName());
        // use a fake function and keep going
        soyFunction = getUnknownFunction(node.getFunctionName(), node.numChildren());
      }

      return SoyJsPluginUtils.applySoyFunction(
          (SoyJsSrcFunction) soyFunction,
          visitChildren(node),
          node.getSourceLocation(),
          errorReporter);
    }
  }
164595
public static ImportNodeData createNodeData(NodeData parent, InternalQName name, InternalQName primaryTypeName,
      int index, int orderNumber)
   {
      ImportNodeData nodeData = null;
      QPath path = QPath.makeChildPath(parent.getQPath(), name, index);
      nodeData =
         new ImportNodeData(path, IdGenerator.generate(), -1, primaryTypeName, new InternalQName[0], orderNumber,
            parent.getIdentifier(), parent.getACL());
      return nodeData;
   }
6125
public static @Nonnull Optional<Class> arrayTypeForPrimitive(String primitiveType) {
        if (primitiveType != null) {
            return Optional.ofNullable(PRIMITIVE_ARRAY_MAP.get(primitiveType));
        }
        return Optional.empty();
    }
1177844
public void setNodeData(byte[] nodeData)
    {
        this.nodeData = (nodeData != null) ? Arrays.copyOf(nodeData, nodeData.length) : null;
    }
1222400
public T fetchSingleOrNull() throws InstantiationException, IllegalAccessException, SQLException {
        if (!finished) {
            T result = primitive ? fetchSinglePrimitiveInternal() : fetchSingleInternal();
            next();
            return result;
        } else {
            return null;
        }
    }