Package com.hp.hpl.jena.datatypes.xsd

Examples of com.hp.hpl.jena.datatypes.xsd.XSDDateTime


                return new NodeValueDouble(d, node) ;
            }

            if ( XSDDatatype.XSDdateTime.isValidLiteral(lit) )
            {
                XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
                return new NodeValueDateTime(dateTime, node) ;
            }
           
            if ( XSDDatatype.XSDdate.isValidLiteral(lit) )
            {
                // Jena datatype support works on masked dataTimes.
                XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
                return new NodeValueDate(dateTime, node) ;
            }
           
            if ( XSDDatatype.XSDtime.isValidLiteral(lit) )
            {
                // Jena datatype support works on masked dataTimes.
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueTime(time, node) ;
            }
           
            if ( XSDDatatype.XSDgYear.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueGYear(time, node) ;
            }
            if ( XSDDatatype.XSDgYearMonth.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueGYearMonth(time, node) ;
            }
            if ( XSDDatatype.XSDgMonth.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueGMonth(time, node) ;
            }
            if ( XSDDatatype.XSDgMonthDay.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueGMonthDay(time, node) ;
            }
            if ( XSDDatatype.XSDgDay.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueGDay(time, node) ;
            }
           
            if ( XSDDatatype.XSDduration.isValidLiteral(lit) )
            {
View Full Code Here


   
    public static final String defaultTimezone = "Z" ;
   
    private static int compareDateTimeFO(NodeValue nv1, NodeValue nv2)
    {
        XSDDateTime dt1 = nv1.getDateTime() ;
        XSDDateTime dt2 = nv2.getDateTime() ;
       
        int x = compareXSDDateTime(dt1, dt2) ;
       
        if ( x == XSDDateTime.INDETERMINATE )
        {
            NodeValue nv3 = fixupDateTime(nv1) ;
            if ( nv3 != null )
            {
                XSDDateTime dt3 = nv3.getDateTime() ;
                x =  compareXSDDateTime(dt3, dt2) ;
                if ( x == XSDDateTime.INDETERMINATE )
                    throw new ARQInternalErrorException("Still get indeterminate comparison") ;
                return x ;
            }
           
            nv3 = fixupDateTime(nv2) ;
            if ( nv3 != null )
            {
                XSDDateTime dt3 = nv3.getDateTime() ;
                x =  compareXSDDateTime(dt1, dt3) ;
                if ( x == XSDDateTime.INDETERMINATE )
                    throw new ARQInternalErrorException("Still get indeterminate comparison") ;
                return x ;
            }
View Full Code Here

   
    // XXX Remove??
    // This only differs by some "dateTime" => "date"
    private static int compareDateFO(NodeValue nv1, NodeValue nv2)
    {
        XSDDateTime dt1 = nv1.getDateTime() ;
        XSDDateTime dt2 = nv2.getDateTime() ;

        int x = compareXSDDateTime(dt1, dt2) ;    // Yes - compareDateTIme
        if ( x == XSDDateTime.INDETERMINATE )
        {
            NodeValue nv3 = fixupDate(nv1) ;
            if ( nv3 != null )
            {
                XSDDateTime dt3 = nv3.getDateTime() ;
                x =  compareXSDDateTime(dt3, dt2) ;
                if ( x == XSDDateTime.INDETERMINATE )
                    throw new ARQInternalErrorException("Still get indeterminate comparison") ;
                return x ;
            }
           
            nv3 = fixupDate(nv2) ;
            if ( nv3 != null )
            {
                XSDDateTime dt3 = nv3.getDateTime() ;
                x =  compareXSDDateTime(dt1, dt3) ;
                if ( x == XSDDateTime.INDETERMINATE )
                    throw new ARQInternalErrorException("Still get indeterminate comparison") ;
                return x ;
            }
View Full Code Here

    {
        // http://www.w3.org/TR/xpath-functions/#casting-to-datetimes
        if ( ! nv.hasDateTime() )
            throw new ExprEvalTypeException("Not a date/time type: "+nv) ;
       
        XSDDateTime xsdDT = nv.getDateTime() ;
       
        if ( XSDDatatype.XSDdateTime.equals(xsd) )
        {
            // ==> DateTime
            if ( nv.isDateTime() ) return nv ;
            if ( ! nv.isDate() ) throw new ExprEvalTypeException("Can't cast to XSD:dateTime: "+nv) ;
            // DateTime with time 00:00:00
            String x = String.format("%04d-%02d-%02dT00:00:00", xsdDT.getYears(), xsdDT.getMonths(),xsdDT.getDays()) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        if ( XSDDatatype.XSDdate.equals(xsd) )
        {
            // ==> Date
            if ( nv.isDate() ) return nv ;
            if ( ! nv.isDateTime() ) throw new ExprEvalTypeException("Can't cast to XSD:date: "+nv) ;
            String x = String.format("%04d-%02d-%02d", xsdDT.getYears(), xsdDT.getMonths(),xsdDT.getDays()) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        if ( XSDDatatype.XSDtime.equals(xsd) )
        {
            // ==> time
            if ( nv.isTime() ) return nv ;
            if ( ! nv.isDateTime() ) throw new ExprEvalTypeException("Can't cast to XSD:time: "+nv) ;
            // Careful foratting
            DecimalFormat nf = new DecimalFormat("00.####") ;
            nf.setDecimalSeparatorAlwaysShown(false) ;
            String x = nf.format(xsdDT.getSeconds()) ;
            x = String.format("%02d:%02d:%s", xsdDT.getHours(), xsdDT.getMinutes(),x) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        if ( XSDDatatype.XSDgYear.equals(xsd) )
        {
            // ==> Year
            if ( nv.isGYear() ) return nv ;
            if ( ! nv.isDateTime() && ! nv.isDate() ) throw new ExprEvalTypeException("Can't cast to XSD:gYear: "+nv) ;
            String x = String.format("%04d", xsdDT.getYears()) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        if ( XSDDatatype.XSDgYearMonth.equals(xsd) )
        {
            // ==> YearMonth
            if ( nv.isGYearMonth() ) return nv ;
            if ( ! nv.isDateTime() && ! nv.isDate() ) throw new ExprEvalTypeException("Can't cast to XSD:gYearMonth: "+nv) ;
            String x = String.format("%04d-%02d", xsdDT.getYears(), xsdDT.getMonths()) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        if ( XSDDatatype.XSDgMonth.equals(xsd) )
        {
            // ==> Month
            if ( nv.isGMonth() ) return nv ;
            if ( ! nv.isDateTime() && ! nv.isDate() ) throw new ExprEvalTypeException("Can't cast to XSD:gMonth: "+nv) ;
            String x = String.format("--%02d", xsdDT.getMonths()) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        if ( XSDDatatype.XSDgMonthDay.equals(xsd) )
        {
            // ==> MonthDay
            if ( nv.isGMonthDay() ) return nv ;
            if ( ! nv.isDateTime() && ! nv.isDate() ) throw new ExprEvalTypeException("Can't cast to XSD:gMonthDay: "+nv) ;
            String x = String.format("--%02d-%02d", xsdDT.getMonths(), xsdDT.getDays()) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        if ( XSDDatatype.XSDgDay.equals(xsd) )
        {
            // Day
            if ( nv.isGDay() ) return nv ;
            if ( ! nv.isDateTime() && ! nv.isDate() ) throw new ExprEvalTypeException("Can't cast to XSD:gDay: "+nv) ;
            String x = String.format("---%02d", xsdDT.getDays()) ;
            return NodeValue.makeNode(x, xsd) ;
        }
   
        throw new ExprEvalTypeException("Can't case to <"+xsd.getURI()+">: "+nv) ;
    }
View Full Code Here

            // XXX Pending Jena update ...
            if ( ( datatype.equals(XSDdateTime) || dtXSDdateTimeStamp.equals(datatypeURI) ) &&
                    XSDdateTime.isValid(lex) )
            {
                XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDdate) && XSDdate.isValidLiteral(lit) )
            {
                // Jena datatype support works on masked dataTimes.
                XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDtime) && XSDtime.isValidLiteral(lit) )
            {
                // Jena datatype support works on masked dataTimes.
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDgYear) && XSDgYear.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
            if ( datatype.equals(XSDgYearMonth) && XSDgYearMonth.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
            if ( datatype.equals(XSDgMonth) && XSDgMonth.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDgMonthDay) && XSDgMonthDay.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
            if ( datatype.equals(XSDgDay) && XSDgDay.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            // XXX Pending Jena update ...
            if ( ( datatype.equals(XSDduration) ||
View Full Code Here

    public static int compareInstants(Node n1, Node n2) {
        if (n1.isLiteral() && n2.isLiteral()) {
            Object v1 = n1.getLiteralValue();
            Object v2 = n2.getLiteralValue();
            if (v1 instanceof XSDDateTime && v2 instanceof XSDDateTime) {
                XSDDateTime a = (XSDDateTime) v1;
                XSDDateTime b = (XSDDateTime) v2;
                return a.compare(b);
            }
        }
        throw new ClassCastException("Non-numeric literal in compareNumbers");
    }
View Full Code Here

    public static int compareTypedLiterals(Node n1, Node n2) {
        if (n1.isLiteral() && n2.isLiteral()) {
            Object v1 = n1.getLiteralValue();
            Object v2 = n2.getLiteralValue();
            if (v1 instanceof XSDDateTime && v2 instanceof XSDDateTime) {
                XSDDateTime a = (XSDDateTime) v1;
                XSDDateTime b = (XSDDateTime) v2;
                return a.compare(b);
            } else {
                if (v1 instanceof Number && v2 instanceof Number) {
                    if (v1 instanceof Float || v1 instanceof Double
                            || v2 instanceof Float || v2 instanceof Double) {
View Full Code Here

    /**
     * Create a typed literal xsd:dateTime from a Calendar object.
     */
    @Override
    public Literal createTypedLiteral(Calendar cal) {
        Object value = new XSDDateTime(cal);
        LiteralLabel ll = LiteralLabelFactory.create(value, "", XSDDatatype.XSDdateTime);
        return new LiteralImpl(NodeFactory.createLiteral(ll), this);

    }
View Full Code Here

            // XXX Pending Jena update ...
            if ( ( datatype.equals(XSDdateTime) || dtXSDdateTimeStamp.equals(datatypeURI) ) &&
                    XSDdateTime.isValid(lex) )
            {
                XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDdate) && XSDdate.isValidLiteral(lit) )
            {
                // Jena datatype support works on masked dataTimes.
                XSDDateTime dateTime = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDtime) && XSDtime.isValidLiteral(lit) )
            {
                // Jena datatype support works on masked dataTimes.
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDgYear) && XSDgYear.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
            if ( datatype.equals(XSDgYearMonth) && XSDgYearMonth.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
            if ( datatype.equals(XSDgMonth) && XSDgMonth.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            if ( datatype.equals(XSDgMonthDay) && XSDgMonthDay.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
            if ( datatype.equals(XSDgDay) && XSDgDay.isValidLiteral(lit) )
            {
                XSDDateTime time = (XSDDateTime)lit.getValue() ;
                return new NodeValueDT(lex, node) ;
            }
           
            // XXX Pending Jena update ...
            if ( ( datatype.equals(XSDduration) ||
View Full Code Here

        @Override
        public Literal createTypedLiteral( Object value ) {
            LiteralLabel ll = null;
            if (value instanceof Calendar) {
                Object valuec = new XSDDateTime( (Calendar) value);
                ll = LiteralLabelFactory.create(valuec, "", XSDDatatype.XSDdateTime);
            } else {
                ll =  LiteralLabelFactory.create(value);
            }
            return new LiteralImpl(Node.createLiteral( ll ), null) ;
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.datatypes.xsd.XSDDateTime

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.