Package xbird.xquery.type

Examples of xbird.xquery.type.Type


            final JPopupMenu menu = new JPopupMenu();
            menu.add(new AbstractAction("Show InferredType") {
                public void actionPerformed(ActionEvent e) {
                    String selected = (String) cell.getUserObject();
                    XQExpression expr = sourceExprMap.get(selected);
                    Type type = expr.getType();
                    JOptionPane.showMessageDialog(frame, (type == null) ? "nil" : type);
                }
            });
            menu.add(new AbstractAction("Eval Expression") {
                public void actionPerformed(ActionEvent e) {
View Full Code Here


    public byte getByte() throws XQException {
        ensureNotClosed();
        final Item item = item_;
        if(item instanceof XNumber) {
            final Type type = item.getType();
            if(type instanceof DecimalType) {
                XNumber num = (XNumber) item;
                final long lv = num.asLong();
                if(!ByteType.inRange(lv)) {
                    throw new XQException("The value must be in the value space of byte: " + lv, "err:XQJxxxx");
View Full Code Here

    public int getInt() throws XQException {
        ensureNotClosed();
        final Item item = item_;
        if(item instanceof XNumber) {
            final Type type = item.getType();
            if(type instanceof DecimalType) {
                XNumber num = (XNumber) item;
                final long lv = num.asLong();
                if(!IntType.inRange(lv)) {
                    throw new XQException("The value must be in the value space of int: " + lv, "err:XQJxxxx");
View Full Code Here

    public String getItemAsString(Properties props) throws XQException {
        return item_.toString();
    }

    public XQItemType getItemType() throws XQException {
        final Type type = item_.getType();
        return new BXQItemType(type);
    }
View Full Code Here

        final Type type = item_.getType();
        return new BXQItemType(type);
    }

    public long getLong() throws XQException {
        final Type type = item_.getType();
        if(type instanceof DecimalType) {
            final DecimalType dt = (DecimalType) type;
            final String sv = item_.stringValue();
            try {
                dt.createInstance(sv, LongType.LONG, DynamicContext.DUMMY);
View Full Code Here

        }
        throw new XQException("Unexpected item class: " + item.getClass().getName());
    }

    public short getShort() throws XQException {
        final Type type = item_.getType();
        if(type instanceof DecimalType) {
            final DecimalType dt = (DecimalType) type;
            final String sv = item_.stringValue();
            try {
                dt.createInstance(sv, ShortType.SHORT, DynamicContext.DUMMY);
View Full Code Here

        return statEnv_.isConstructionModeStrip() ? CONSTRUCTION_MODE_STRIP
                : CONSTRUCTION_MODE_PRESERVE;
    }

    public XQItemType getContextItemStaticType() {
        final Type rawType = statEnv_.getContextItemStaticType();
        return new BXQItemType(rawType);
    }
View Full Code Here

    public void setContextItemStaticType(XQItemType contextItemType) {
        if(contextItemType == null) {
            statEnv_.setContextItemStaticType(null);
        } else if(contextItemType instanceof BXQItemType) {
            Type type = ((BXQItemType) contextItemType).getInternalType();
            statEnv_.setContextItemStaticType(type);
        }
        throw new UnsupportedOperationException("Unexpected type: " + contextItemType);//TODO
    }
View Full Code Here

            return subtypeOf(src, trg);
        }
    }

    public static boolean isPromotable(final Type src, final AtomicType trg) {
        final Type primeType = src.prime();
        if(primeType instanceof AtomicType) {
            return TypeTable.isCastable((AtomicType) primeType, trg, true);
        } else if(primeType instanceof ChoiceType) {
            final ChoiceType choise = (ChoiceType) primeType;
            for(Type c : choise.getTypes()) {
View Full Code Here

        }
    }

    public static XQExpression promote(final XQExpression expr, final Type destType)
            throws TypeError {
        final Type srcType = expr.getType();
        if(TypeUtil.subtypeOf(srcType, destType)) {
            return expr;
        } else {
            if(TypeUtil.isPromotable(srcType, destType)) {
                return new TypePromotedExpr(expr, destType, true);
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.