Package xbird.xquery.type

Examples of xbird.xquery.type.Type


    public XQExpression staticAnalysis(StaticContext statEnv) throws XQueryException {
        if(!_analyzed) {
            this._analyzed = true;
            this._leftOperand = _leftOperand.staticAnalysis(statEnv);
            this._rightOperand = _rightOperand.staticAnalysis(statEnv);
            final Type integerType = TypeRegistry.safeGet("xs:integer?");
            if(!TypeUtil.subtypeOf(_leftOperand.getType(), integerType)) {
                throw new TypeError("Inferred type of left operand is invalid: "
                        + _leftOperand.getType());
            }
            if(!TypeUtil.subtypeOf(_rightOperand.getType(), integerType)) {
View Full Code Here


    public String toString() {
        return ".";
    }

    public XQExpression staticAnalysis(StaticContext statEnv) throws XQueryException {
        Type curType = statEnv.getContextItemStaticType();
        if(curType != null) {
            this._type = curType;
        }
        return this;
    }
View Full Code Here

        if(!_analyzed) {
            this._analyzed = true;
            XQExpression src = _srcExpr.staticAnalysis(statEnv);
            EagarAnnotator annotator = new EagarAnnotator();
            annotator.visit(src, null);
            Type inferredType = src.getType();
            this._srcExpr = src;
            for(int i = 0; i < _predicates.size(); i++) {
                XQExpression p = _predicates.get(i);
                statEnv.setContextItemStaticType(inferredType);
                XQExpression anylyzed = p.staticAnalysis(statEnv);
View Full Code Here

     */
    private AbstractXQExpression simplify(StaticContext statEnv) throws XQueryException {
        if(TypeUtil.subtypeOf(_type, SequenceType.EMPTY)) {
            return SequenceExpression.EMPTY_SEQUENCE;
        }
        Type baseType = _srcExpr.getType();
        for(int i = 0; i < _predicates.size(); i++) {
            XQExpression e = _predicates.get(i);
            if(e instanceof LiteralExpr) {
                AtomicValue literal = ((LiteralExpr) e).getValue();
                if(literal instanceof XNumber) {
View Full Code Here

            Sequence result = _result;
            if(result == null) {
                throw new DynamicError("External variable '$" + getName() + "' is not set");
            }
            if(checkType) {
                final Type resultType = result.getType();
                if(!TypeUtil.subtypeOf(resultType, _type)) {
                    result = DirectFunctionCall.mapFunctionArgument(_result, _type, dynEnv);
                }
            }
            return result;
View Full Code Here

            throws XQueryException {
        assert (argv != null);
        assert (expectedArgType != null);
        // If the function expects atomic parameters, then fn:data is called
        // to obtain them.
        final Type primeType = expectedArgType.prime();
        if(primeType instanceof AtomicType) {
            // Inserts conversions of function arguments that depend only on
            // the expected SequenceType of the corresponding parameters.
            if(expectedArgType instanceof SequenceType) {
                expectedArgType = ((SequenceType) expectedArgType).prime();
            }
            if(!(expectedArgType instanceof AtomicType)) {
                throw new TypeError("expectedArgType must be built-in atomic type, but was "
                        + expectedArgType);
            }
            final AtomicType expected = (AtomicType) expectedArgType;
            final ValueSequence res = new ValueSequence(dynEnv);
            final IFocus<? extends Item> atomizedItor = argv.atomize(dynEnv).iterator();
            for(Item it : atomizedItor) {
                final Type actualType = it.getType();
                // apply fs:ConvertSimpleOperand
                if(actualType == UntypedAtomicType.UNTYPED_ATOMIC && expected.getTypeId() >= 0) {
                    final AtomicValue casted = ((AtomicValue) it).castAs(expected, dynEnv);
                    res.addItem(casted);
                } else {
View Full Code Here

     TODO: err:XPTY0004, err:XQST0054, err:XP0006
    ************************************************************************/
    final public void parseVarDecl() throws ParseException, XQueryException {
        final QualifiedName varName;
        Type varType = null;
        XQExpression valueExpr = null;
        boolean isExternal = false;
        currentToken = jj_consume_token(DefineVariable);
        // TODO spaces afrer "$"
        currentToken = jj_consume_token(VarName);
View Full Code Here

    ************************************************************************/
    final public void parseFunctionDecl() throws ParseException, XQueryException {
        final UserFunction func;
        final QualifiedName funcName;
        List<ParametricVariable> paramList = Collections.<ParametricVariable> emptyList();
        Type returnType = Untyped.UNTYPED;
        final XQExpression funcBody;
        currentModule.pushVarScope();
        currentToken = jj_consume_token(DefineFunction);
        currentToken = jj_consume_token(QNameLpar);
        funcName = QNameUtil.parse(currentToken.image.substring(0, currentToken.image.length() - 1).trim(), namespaceContext, staticContext.getDefaultFunctionNamespace());
View Full Code Here

    ************************************************************************/
    final public List<ParametricVariable> parseParamList() throws ParseException, XQueryException {
        final List<ParametricVariable> paramList = new LinkedList<ParametricVariable>();
        QualifiedName paramName;
        ParametricVariable param;
        Type paramType = null;
        currentToken = jj_consume_token(VariableIndicator);
        currentToken = jj_consume_token(VarName);
        paramName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
        param = new ParametricVariable(paramName);
        currentModule.putVariable(paramName, param);
View Full Code Here

    ************************************************************************/
    final public List<Binding> parseForClause() throws ParseException, XQueryException {
        final List<Binding> fors;
        ForClause clause;
        ForVariable var;
        Type varType = null;
        XQExpression expr;
        currentToken = jj_consume_token(ForVariable);
        currentToken = jj_consume_token(VarName);
        QualifiedName varName = QNameUtil.parse(currentToken.image, namespaceContext, currentModule.getNamespace());
        var = new ForVariable(varName);
View Full Code Here

TOP

Related Classes of xbird.xquery.type.Type

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.