/** * @param closureValue * to be mapped, '-' will be replaced with '_' * @return the closure value or closed. */ public static Closure fromString( String closureValue ) { Closure result = Closure.closed; if ( closureValue != null && !"".equals( closureValue ) ) { String mapped = closureValue.replaceAll( "-", "_" ); try { result = Closure.valueOf( mapped.toLowerCase() ); } catch ( NullPointerException e ) { // nothing, just use closed as a default. } } return result; }
SingleValue<?> min = mapTT( it.getMin() ); SingleValue<?> max = mapTT( it.getMax() ); Closure closure = Closure.fromString( it.getClosure().get( 0 ) ); intervals.add( new Interval( min, max, closure, null, false, null ) );
/** * @param writer * @param interval * @throws XMLStreamException */ protected static void exportInterval( XMLStreamWriter writer, Interval<?, ?> interval ) throws XMLStreamException { if ( interval != null ) { writer.writeStartElement( WCS_100_NS, "interval" ); writer.writeNamespace( WCS_100_PRE, WCS_100_NS ); if ( interval.getSemantic() != null ) { writer.writeAttribute( WCS_100_PRE, WCS_100_NS, "semantic", interval.getSemantic() ); } writer.writeAttribute( "atomic", interval.isAtomic() ? "true" : "false" ); Closure closure = interval.getClosure(); writer.writeAttribute( WCS_100_PRE, WCS_100_NS, "closure", closure.name().replaceAll( "_", "-" ) ); exportSingleValueType( writer, interval.getMin(), "min" ); exportSingleValueType( writer, interval.getMax(), "max" ); exportSingleValueType( writer, interval.getSpacing(), "res" ); writer.writeEndElement();// WCS_100_NS, "interval" ); } }
private Closure parseClosure( OMElement rootElement ) { String closureValue = rootElement.getAttributeValue( new QName( "closure" ) ); return Closure.fromString( closureValue ); }