/** * Get the interval defined by the given String. * * @param interval * @return */ private static Interval<?, ?> parseInterval( String interval, ValueType type ) { Interval<?, ?> result = null; String[] split = interval.split( "/" ); if ( split.length == 2 || split.length == 3 ) { // should be min/max/res String min = split[0]; String max = split[1]; String res = null; if ( split.length == 3 ) { res = split[2]; } SingleValue<?> spacing = res == null ? null : SingleValue.createFromString( ValueType.Void.name(), res ); result = Interval.createFromStrings( type.toString(), min, max, Closure.closed, null, false, spacing ); } else { LOG.warn( "Given intervall: " + interval + " has not enough values, maybe a default value is ment?" ); } return result; }
/** * Implementation as proposed by Joshua Block in Effective Java (Addison-Wesley 2001), which supplies an even * distribution and is relatively fast. It is created from field <b>f</b> as follows: * <ul> * <li>boolean -- code = (f ? 0 : 1)</li> * <li>byte, char, short, int -- code = (int)f</li> * <li>long -- code = (int)(f ^ (f >>>32))</li> * <li>float -- code = Float.floatToIntBits(f);</li> * <li>double -- long l = Double.doubleToLongBits(f); code = (int)(l ^ (l >>> 32))</li> * <li>all Objects, (where equals( ) calls equals( ) for this field) -- code = f.hashCode( )</li> * <li>Array -- Apply above rules to each element</li> * </ul> * <p> * Combining the hash code(s) computed above: result = 37 * result + code; * </p> * * @return (int) ( result >>> 32 ) ^ (int) result; * * @see java.lang.Object#hashCode() */ @Override public int hashCode() { // the 2nd millionth prime, :-) long result = 32452843; result = result * 37 + this.type.hashCode(); result = result * 37 + this.value.hashCode(); return (int) ( result >>> 32 ) ^ (int) result; }
/** * @param other * to test against * @return true if the given singlevalue matches this one, e.g. the value and types are equal. */ @Override public boolean equals( Object other ) { if ( other != null && other instanceof SingleValue<?> ) { SingleValue<?> that = (SingleValue<?>) other; if ( this.type.isCompatible( that.type ) ) { return ( value == null ) ? that.value == null : value.equals( that.value ); } } return false; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( "{" ).append( type.toString() ).append( "}" ); sb.append( value.toString() ); return sb.toString(); } }
ValueType determined = ValueType.fromString( type ); SingleValue<?> result = null; switch ( determined ) {
@Override public String toString() { return name().toLowerCase(); }
/** * @param writer * @param singleValue * @param elementName * @throws XMLStreamException */ protected static void exportSingleValueType( XMLStreamWriter writer, SingleValue<?> singleValue, String elementName ) throws XMLStreamException { if ( singleValue != null ) { String type = ( singleValue.type == ValueType.Void ) ? ValueType.String.toString() : singleValue.type.toString(); writeElement( writer, WCS_100_NS, elementName, singleValue.value.toString(), WCS_100_NS, WCS_100_PRE, "type", type, true ); } }
ValueType determined = ValueType.fromString( type ); SingleValue<?> result = null; switch ( determined ) {
for ( String sv : split ) { if ( sv != null ) { singleValues.add( SingleValue.createFromString( ValueType.Void.name(), sv ) );
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append( "{" ).append( min.type.toString() ).append( "}" ); sb.append( closure.begin ).append( min.value.toString() ).append( "/" ).append( max.value.toString() ).append( closure.end ); if ( spacing != null ) { sb.append( "/" ).append( spacing.toString() ); } return sb.toString(); }
ValueType t = ValueType.fromString( type ); if ( t != min.type ) { throw new OWSException(
if ( newType != null && newType != ValueType.Void && type == ValueType.Void ) { String type = newType.name(); if ( intervals != null && !intervals.isEmpty() ) { this.type = newType;
/** * @param inter * to check against * @return true if this interval is in the bounds of the given interval. */ @SuppressWarnings("unchecked") public boolean isInBounds( Interval<?, ?> inter ) { // unchecked is suppressed because it is actually checked. boolean result = false; if ( inter != null ) { if ( inter.min.type.isCompatible( min.type ) ) { int comp = min.value.compareTo( (T) inter.min.value ); // min fit true if this min value > given min value result = match( comp, inter.closure, true ); if ( result ) { // min is in the interval if the this min value < max value comp = min.value.compareTo( (T) inter.max.value ); result = match( comp, inter.closure, false ); if ( result ) { // so min values match, lets check the max value against max (assuming min > max ) comp = max.value.compareTo( (T) inter.max.value ); result = match( comp, inter.closure, false ); } } } } return result; }
if ( min.type != sv.type ) { if ( min.type == ValueType.Void ) { tmpInter = Interval.createFromStrings( sv.type.toString(), tmpInter.getMin().value.toString(), tmpInter.getMax().value.toString(), tmpInter.getSpacing() ); } else if ( sv.type == ValueType.Void ) { sv = SingleValue.createFromString( min.type.toString(), sv.value.toString() ); } else { continue;
boolean atomic, SingleValue<RS> resolution ) { ValueType determined = ValueType.fromString( type ); Interval<?, RS> result = null; switch ( determined ) {