/** * @param axisSubset */ @SuppressWarnings("unchecked") private <T extends Comparable<T>> boolean isValid( T value, AxisSubset axisSubset ) { List<Interval<?, ?>> intervals = axisSubset.getIntervals(); List<SingleValue<?>> singleValues = axisSubset.getSingleValues(); boolean isValid = false; if ( intervals != null && !intervals.isEmpty() ) { Iterator<Interval<?, ?>> it = intervals.iterator(); while ( it.hasNext() && !isValid ) { try { isValid = ( (Interval<T, ?>) it.next() ).liesWithin( value ); } catch ( ClassCastException cc ) { // mmm, this should never happen, but just to make sure. } } } if ( !isValid && singleValues != null && !singleValues.isEmpty() ) { Iterator<SingleValue<?>> it = singleValues.iterator(); while ( it.hasNext() && !isValid ) { try { isValid = ( (SingleValue<T>) it.next() ).value.equals( value ); } catch ( ClassCastException cc ) { // mmm, this should never happen, but just to make sure. } } } return isValid; }
/** * @param writer * @param axisDescriptions * @throws XMLStreamException */ protected static void exportAxisDescriptions( XMLStreamWriter writer, List<AxisSubset> axisDescriptions ) throws XMLStreamException { if ( !axisDescriptions.isEmpty() ) { for ( AxisSubset ass : axisDescriptions ) { if ( ass != null ) { writer.writeStartElement( WCS_100_NS, "axisDescription" ); writer.writeStartElement( WCS_100_NS, "AxisDescription" ); writeElement( writer, WCS_100_NS, "name", ass.getName() ); writeElement( writer, WCS_100_NS, "label", ass.getLabel() ); writer.writeStartElement( WCS_100_NS, "values" ); exportIntervals( writer, ass.getIntervals() ); if ( ass.getSingleValues() != null ) { for ( SingleValue<?> sv : ass.getSingleValues() ) { exportSingleValueType( writer, sv, "singleValue" ); } } writer.writeEndElement();// WCS_100_NS, "values" ); writer.writeEndElement();// WCS_100_NS, "AxisDescription" ); writer.writeEndElement();// WCS_100_NS, "axisDescription" ); } } } }
/** * @param other * @param convert * if true the intervals and singlevalues of this instance will be converted to the type of the given * axis subset if their names match and if this type is unknown (void). * @return true if this {@link AxisSubset} matches the given AxisSubset, e.g. if the names are equal and the axis * values have matching parameters in the given one. */ public boolean match( AxisSubset other, boolean convert ) { boolean result = other.getName().equalsIgnoreCase( name ); if ( result ) { if ( this.type == ValueType.Void && convert ) { convertTypes( other.getType() ); } boolean ic = checkIntervals( other.getIntervals() ); boolean sc = checkSingles( other.getSingleValues(), other.getIntervals() ); result = ic && sc; } return result; }