Package org.apache.xmlbeans

Examples of org.apache.xmlbeans.GDuration


    public SchemaType schemaType() { return _schemaType; }

    protected void set_text(String s)
    {
        GDuration newVal;
        if (_validateOnSet())
            newVal = validateLexical(s, _schemaType, _voorVc);
        else
            newVal = lex(s, _voorVc);
View Full Code Here


            validateValue(v, _schemaType, _voorVc);
       
        if (v.isImmutable() && (v instanceof GDuration))
            _value = (GDuration)v;
        else
            _value = new GDuration(v);
    }
View Full Code Here

        return _value == null ? null : _value;
    }

    public static GDuration lex(String v, ValidationContext context)
    {
        GDuration duration = null;
       
        try
        {
            duration = new GDuration(v);
        }
        catch (Exception e)
        {
            context.invalid(XmlErrorCodes.DURATION, new Object[] { v });
        }
View Full Code Here

        return duration;
    }

    public static GDuration validateLexical(String v, SchemaType sType, ValidationContext context)
    {
        GDuration duration = lex(v, context);

        if (duration != null && sType.hasPatternFacet())
            if (!sType.matchPatternFacet(v))
                context.invalid(XmlErrorCodes.DATATYPE_VALID$PATTERN_VALID,
                    new Object[] { "duration", v, QNameHelper.readable(sType) });
View Full Code Here

    }

    public static void validateValue(GDurationSpecification v, SchemaType sType, ValidationContext context)
    {
        XmlObject x;
        GDuration g;
       
        if ((x = sType.getFacet(SchemaType.FACET_MIN_EXCLUSIVE)) != null)
            if (v.compareToGDuration(g = ((XmlObjectBase)x).gDurationValue()) <= 0)
                context.invalid(XmlErrorCodes.DATATYPE_MIN_EXCLUSIVE_VALID,
                    new Object[] { "duration", v, g, QNameHelper.readable(sType) });
View Full Code Here

                        set_notation(s);
                        break;
                    }
                    case SchemaType.BTC_DURATION:
                    {
                        GDuration gd = ((SimpleValue)v).getGDurationValue();
                        set_prepare();
                        set_GDuration(gd);
                        break;
                    }
                    case SchemaType.BTC_DATE_TIME:
View Full Code Here

            _gdateValue = d;
            break;
        }
        case SchemaType.BTC_DURATION :
        {
            GDuration d = XmlDurationImpl.validateLexical( value, type, _vc );

            if (d != null)
                XmlDurationImpl.validateValue( d, type, _vc );

            _gdurationValue = d;
View Full Code Here

                        set_notation(s);
                        break;
                    }
                    case SchemaType.BTC_DURATION:
                    {
                        GDuration gd = ((SimpleValue)v).getGDurationValue();
                        set_prepare();
                        set_GDuration(gd);
                        break;
                    }
                    case SchemaType.BTC_DATE_TIME:
View Full Code Here

  }

  private String formatDuration( SchemaType sType )
  {
    XmlDuration d = ( XmlDuration )sType.getFacet( SchemaType.FACET_MIN_INCLUSIVE );
    GDuration minInclusive = null;
    if( d != null )
      minInclusive = d.getGDurationValue();

    d = ( XmlDuration )sType.getFacet( SchemaType.FACET_MAX_INCLUSIVE );
    GDuration maxInclusive = null;
    if( d != null )
      maxInclusive = d.getGDurationValue();

    d = ( XmlDuration )sType.getFacet( SchemaType.FACET_MIN_EXCLUSIVE );
    GDuration minExclusive = null;
    if( d != null )
      minExclusive = d.getGDurationValue();

    d = ( XmlDuration )sType.getFacet( SchemaType.FACET_MAX_EXCLUSIVE );
    GDuration maxExclusive = null;
    if( d != null )
      maxExclusive = d.getGDurationValue();

    GDurationBuilder gdurb = new GDurationBuilder();
    @SuppressWarnings( "unused" )
    BigInteger min, max;

    gdurb.setSecond( pick( 800000 ) );
    gdurb.setMonth( pick( 20 ) );

    // Years
    // Months
    // Days
    // Hours
    // Minutes
    // Seconds
    // Fractions
    if( minInclusive != null )
    {
      if( gdurb.getYear() < minInclusive.getYear() )
        gdurb.setYear( minInclusive.getYear() );
      if( gdurb.getMonth() < minInclusive.getMonth() )
        gdurb.setMonth( minInclusive.getMonth() );
      if( gdurb.getDay() < minInclusive.getDay() )
        gdurb.setDay( minInclusive.getDay() );
      if( gdurb.getHour() < minInclusive.getHour() )
        gdurb.setHour( minInclusive.getHour() );
      if( gdurb.getMinute() < minInclusive.getMinute() )
        gdurb.setMinute( minInclusive.getMinute() );
      if( gdurb.getSecond() < minInclusive.getSecond() )
        gdurb.setSecond( minInclusive.getSecond() );
      if( gdurb.getFraction().compareTo( minInclusive.getFraction() ) < 0 )
        gdurb.setFraction( minInclusive.getFraction() );
    }

    if( maxInclusive != null )
    {
      if( gdurb.getYear() > maxInclusive.getYear() )
        gdurb.setYear( maxInclusive.getYear() );
      if( gdurb.getMonth() > maxInclusive.getMonth() )
        gdurb.setMonth( maxInclusive.getMonth() );
      if( gdurb.getDay() > maxInclusive.getDay() )
        gdurb.setDay( maxInclusive.getDay() );
      if( gdurb.getHour() > maxInclusive.getHour() )
        gdurb.setHour( maxInclusive.getHour() );
      if( gdurb.getMinute() > maxInclusive.getMinute() )
        gdurb.setMinute( maxInclusive.getMinute() );
      if( gdurb.getSecond() > maxInclusive.getSecond() )
        gdurb.setSecond( maxInclusive.getSecond() );
      if( gdurb.getFraction().compareTo( maxInclusive.getFraction() ) > 0 )
        gdurb.setFraction( maxInclusive.getFraction() );
    }

    if( minExclusive != null )
    {
      if( gdurb.getYear() <= minExclusive.getYear() )
        gdurb.setYear( minExclusive.getYear() + 1 );
      if( gdurb.getMonth() <= minExclusive.getMonth() )
        gdurb.setMonth( minExclusive.getMonth() + 1 );
      if( gdurb.getDay() <= minExclusive.getDay() )
        gdurb.setDay( minExclusive.getDay() + 1 );
      if( gdurb.getHour() <= minExclusive.getHour() )
        gdurb.setHour( minExclusive.getHour() + 1 );
      if( gdurb.getMinute() <= minExclusive.getMinute() )
        gdurb.setMinute( minExclusive.getMinute() + 1 );
      if( gdurb.getSecond() <= minExclusive.getSecond() )
        gdurb.setSecond( minExclusive.getSecond() + 1 );
      if( gdurb.getFraction().compareTo( minExclusive.getFraction() ) <= 0 )
        gdurb.setFraction( minExclusive.getFraction().add( new BigDecimal( 0.001 ) ) );
    }

    if( maxExclusive != null )
    {
      if( gdurb.getYear() > maxExclusive.getYear() )
        gdurb.setYear( maxExclusive.getYear() );
      if( gdurb.getMonth() > maxExclusive.getMonth() )
        gdurb.setMonth( maxExclusive.getMonth() );
      if( gdurb.getDay() > maxExclusive.getDay() )
        gdurb.setDay( maxExclusive.getDay() );
      if( gdurb.getHour() > maxExclusive.getHour() )
        gdurb.setHour( maxExclusive.getHour() );
      if( gdurb.getMinute() > maxExclusive.getMinute() )
        gdurb.setMinute( maxExclusive.getMinute() );
      if( gdurb.getSecond() > maxExclusive.getSecond() )
        gdurb.setSecond( maxExclusive.getSecond() );
      if( gdurb.getFraction().compareTo( maxExclusive.getFraction() ) > 0 )
        gdurb.setFraction( maxExclusive.getFraction() );
    }

    gdurb.normalize();
    return gdurb.toString();
  }
View Full Code Here

            _gdateValue = d;
            break;
        }
        case SchemaType.BTC_DURATION :
        {
            GDuration d = XmlDurationImpl.validateLexical( value, type, _vc );

            if (d != null)
                XmlDurationImpl.validateValue( d, type, _vc );

            _gdurationValue = d;
View Full Code Here

TOP

Related Classes of org.apache.xmlbeans.GDuration

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.