/** * Creates a new instance of the object described by this field. * * @param parent * The object for which the field is created * @return A new instance of the field's value * @throws IllegalStateException * This field is a simple type and cannot be instantiated */ public Object newInstance(Object parent) throws IllegalStateException { return new RecurringDuration(); } //-- newInstance
/** * returns a recurringDuration with the facets * duration and period set up but also the fields * @param duration the String representing the duration facet * @param period the String reprensenting the period facet * @param values an array of shorts which contains the values of the fields * @see #setValues */ public RecurringDuration(String duration, String period, short[] values) throws UnsupportedOperationException { this(duration, period); if (values.length != 10) { throw new IllegalArgumentException("Wrong numbers of values"); } this.setValues(values); }
RecurringDuration temp = RecurringDuration.parseRecurringDuration(value.toString()) ; recurTarget.setCentury(temp.getCentury()); recurTarget.setYear(temp.getYear()); recurTarget.setMonth(temp.getMonth()); recurTarget.setDay(temp.getDay()); recurTarget.setHour(temp.getHour()); recurTarget.setMinute(temp.getMinute()); recurTarget.setSecond(temp.getSeconds(), temp.getMilli()); recurTarget.setZone(temp.getZoneHour(),temp.getZoneMinute()); recurTarget.isUTC(); } catch (Exception ex) {
/** * returns an array of short with all the fields which describe * a RecurringDuration * @return an array of short with all the fields which describe * a RecurringDuration */ public short[] getValues() { short[] result = null; result = new short[10]; result[0] = this.getCentury(); result[1] = this.getYear(); result[2] = this.getMonth(); result[3] = this.getDay(); result[4] = this.getHour(); result[5] = this.getMinute(); result[6] = this.getSeconds(); result[7] = this.getMilli(); result[8] = this.getZoneHour(); result[5] = this.getZoneMinute(); return result; } //getValues
if (reccD == null) return false; if ( !(this.getPeriod().equals(reccD.getPeriod())) || !(this.getDuration().equals(reccD.getDuration())) ) throw new ValidationException(err); result = this.getCentury() == reccD.getCentury(); result = result && (this.getYear() == reccD.getYear()); result = result && (this.getMonth() == reccD.getMonth()); result = result && (this.getDay() == reccD.getDay()); result = result && (this.getHour() == reccD.getHour()); result = result && (this.getMinute() == reccD.getMinute()); result = result && (this.getSeconds() == reccD.getSeconds()); result = result && (this.getMilli() == reccD.getMilli()); result = result && (this.isNegative() == this.isNegative()); if (!reccD.isUTC()) { result = result && (!this.isUTC()); result = result && (this.getZoneHour() == reccD.getZoneHour()); result = result && (this.getZoneMinute() == reccD.getZoneMinute());
RecurringDuration result = new RecurringDuration(); result.setNegative(); result.setCentury(Short.parseShort(temp.substring(0, 2))); if (DEBUG) { System.out.println("Processing year: " + temp.substring(2, 4)); result.setYear(Short.parseShort(temp.substring(2, 4))); process = true; result.setCentury(OMITED); if (token.countTokens() == 2) { result.setMonth(Short.parseShort(temp)); process = true; result.setMonth(OMITED); result.setDay(Short.parseShort(temp)); process = true; result.setDay(OMITED); result.setHour(Short.parseShort(temp)); process = true; if (result.getDay() == OMITED) result.setHour(OMITED);
/** * <p> * Returns true if the present instance of RecurringDuration is greater than the parameter * <p> * Note : the order relation follows the W3C XML Schema draft i.e <tt>rd1 < rd2 </tt>iff rd2-rd1>0 * * @param reccD the recurring duration to compare with the present instance * @return true if the present instance is the greatest, false if not */ public boolean isGreater(RecurringDuration reccD) throws ValidationException { boolean result = false; if (!(this.getPeriod().equals(reccD.getPeriod())) || !(this.getDuration().equals(reccD.getDuration()))) { String err = " Recurring Duration which have different values " + "for the duration and period can not be compared"; throw new ValidationException(err); } short[] val_this = this.getValues(); short[] val_reccD = reccD.getValues(); int i = 0; while ((result != true) && (i < (val_this.length - 1))) { result = val_this[i] > val_reccD[i]; if (val_this[i] < val_reccD[i]) return false; i++; } return result; }// isGreater
long randLong = _rand.nextLong(); TimeDuration randDuration = new TimeDuration(randLong); RecurringDuration result = new RecurringDuration(randDuration, randDuration); short[] values = new short[10]; result.setValues(values);
/** * Override the java.lang.equals method * * @see #equal */ public boolean equals(Object object) { if (object instanceof RecurringDuration) { try { return equal((RecurringDuration) object); } catch (ValidationException e) { e.printStackTrace(); return false; } } return false; }
if (reccD == null) return false; if (!(this.getPeriod().equals(reccD.getPeriod())) || !(this.getDuration().equals(reccD.getDuration()))) { String err = " Recurring Duration which have different values " + "for the duration and period can not be compared"; throw new ValidationException(err); result = this.getCentury() == reccD.getCentury(); result = result && (this.getYear() == reccD.getYear()); result = result && (this.getMonth() == reccD.getMonth()); result = result && (this.getDay() == reccD.getDay()); result = result && (this.getHour() == reccD.getHour()); result = result && (this.getMinute() == reccD.getMinute()); result = result && (this.getSeconds() == reccD.getSeconds()); result = result && (this.getMilli() == reccD.getMilli()); result = result && (this.isNegative() == this.isNegative()); if (!reccD.isUTC()) { result = result && (!this.isUTC()); result = result && (this.getZoneHour() == reccD.getZoneHour()); result = result && (this.getZoneMinute() == reccD.getZoneMinute());
RecurringDuration result = new RecurringDuration(); result.setNegative(); result.setCentury(Short.parseShort( temp.substring(0,2) )); if (DEBUG) { System.out.println("Processing year: "+temp.substring(2,4)); result.setYear(Short.parseShort( temp.substring(2,4) )); process = true; result.setCentury(OMITED); if (token.countTokens() == 2) { result.setMonth(Short.parseShort(temp)); process = true; result.setMonth(OMITED); result.setDay(Short.parseShort(temp)); process = true; result.setDay(OMITED); result.setHour(Short.parseShort( temp )); process = true; if (result.getDay() == OMITED ) result.setHour(OMITED);
/** * returns an array of short with all the fields which describe a RecurringDuration * * @return an array of short with all the fields which describe a RecurringDuration */ public short[] getValues() { short[] result = null; result = new short[10]; result[0] = this.getCentury(); result[1] = this.getYear(); result[2] = this.getMonth(); result[3] = this.getDay(); result[4] = this.getHour(); result[5] = this.getMinute(); result[6] = this.getSeconds(); result[7] = this.getMilli(); result[8] = this.getZoneHour(); result[5] = this.getZoneMinute(); return result; } // getValues
/** * <p>Returns true if the present instance of RecurringDuration is greater than * the parameter * <p>Note : the order relation follows the W3C XML Schema draft i.e * <tt>rd1 < rd2 </tt>iff rd2-rd1>0 * @param reccD the recurring duration to compare with the present instance * @return true if the present instance is the greatest, false if not */ public boolean isGreater(RecurringDuration reccD) throws ValidationException { boolean result = false; if ( !(this.getPeriod().equals(reccD.getPeriod())) || !(this.getDuration().equals(reccD.getDuration())) ) { String err = " Recurring Duration which have different values " +"for the duration and period can not be compared"; throw new ValidationException(err); } short[] val_this = this.getValues(); short[] val_reccD = reccD.getValues(); int i = 0; while ( (result != true) && (i< (val_this.length-1)) ) { result = val_this[i] > val_reccD[i]; if ( val_this[i] < val_reccD[i]) return false; i++; } return result; }//isGreater
/** * Override the java.lang.equals method * @see #equal */ public boolean equals(Object object) { if (object instanceof RecurringDuration) { try { return equal( (RecurringDuration) object); } catch (ValidationException e) { e.printStackTrace(); return false; } } return false; }
/** * Sets the value of the field associated with this descriptor. * * @param target the object in which to set the value * @param value the value of the field */ public void setValue(Object target, Object value) throws java.lang.IllegalStateException { if (!(target instanceof RecurringDuration)) { // -- throw exception } RecurringDuration recurTarget = (RecurringDuration) target; if (value == null) { /// do something } // -- update current instance of time with new time try { RecurringDuration temp = RecurringDuration.parseRecurringDuration(value.toString()); recurTarget.setCentury(temp.getCentury()); recurTarget.setYear(temp.getYear()); recurTarget.setMonth(temp.getMonth()); recurTarget.setDay(temp.getDay()); recurTarget.setHour(temp.getHour()); recurTarget.setMinute(temp.getMinute()); recurTarget.setSecond(temp.getSeconds(), temp.getMilli()); recurTarget.setZone(temp.getZoneHour(), temp.getZoneMinute()); recurTarget.isUTC(); } catch (Exception ex) { // -- ignore for now } } // -- setValue
if (this.getCentury() == -1) result.append('-'); else { if (this.getCentury()/10 == 0) result.append(0); result.append(this.getCentury()); if ((this.getYear()/10) == 0) result.append(0); result.append(this.getYear()); if (this.getMonth() == -1) result.append('-'); else { if ((this.getMonth() / 10) == 0 ) result.append(0); result.append(this.getMonth()); if (this.getDay() == -1) result.append('-'); else { if ((this.getDay()/10) == 0 ) result.append(0); result.append(this.getDay()); if (this.getHour() == -1) result.append('-'); else { if ((this.getHour()/10) == 0)
/** * Creates a new instance of the object described by this field. * * @param parent The object for which the field is created * @return A new instance of the field's value * @throws IllegalStateException This field is a simple type and cannot be instantiated */ public Object newInstance(Object parent) throws IllegalStateException { return new RecurringDuration(); } // -- newInstance
/** * returns a recurringDuration with the facets duration and period set up but also the fields * * @param duration the String representing the duration facet * @param period the String reprensenting the period facet * @param values an array of shorts which contains the values of the fields * @see #setValues */ public RecurringDuration(String duration, String period, short[] values) throws UnsupportedOperationException { this(duration, period); if (values.length != 10) { throw new IllegalArgumentException("Wrong numbers of values"); } this.setValues(values); }
if (this.getCentury() == -1) result.append('-'); else { if (this.getCentury() / 10 == 0) result.append(0); result.append(this.getCentury()); if ((this.getYear() / 10) == 0) result.append(0); result.append(this.getYear()); if (this.getMonth() == -1) result.append('-'); else { if ((this.getMonth() / 10) == 0) result.append(0); result.append(this.getMonth()); if (this.getDay() == -1) result.append('-'); else { if ((this.getDay() / 10) == 0) result.append(0); result.append(this.getDay()); if (this.getHour() == -1) result.append('-'); else { if ((this.getHour() / 10) == 0)
/** * returns a recurringDurationBase with the facets duration and period set up but also the fields * * @param duration the String representing the duration facet * @param period the String reprensenting the period facet * @param values an array of shorts which contains the values of the fields * @throws IllegalArgumentException this exception is thrown when the values array is not of * length 6. * @see #setValues */ protected RecurringDurationBase(String duration, String period, short[] values) throws OperationNotSupportedException { new RecurringDuration(duration, period); if (values.length != 6) { throw new IllegalArgumentException("Wrong numbers of values"); } this.setValues(values); }