All Downloads are FREE. Search and download functionalities are using the official Maven repository.

it.geosolutions.geoserver.rest.decoder.RESTStructuredCoverageIndexSchema Maven / Gradle / Ivy

/*
 *  GeoServer-Manager - Simple Manager Library for GeoServer
 *  
 *  Copyright (C) 2007,2011 GeoSolutions S.A.S.
 *  http://www.geo-solutions.it
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */
package it.geosolutions.geoserver.rest.decoder;

import it.geosolutions.geoserver.rest.decoder.utils.JDOMBuilder;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;

import org.jdom.Element;

/**
 * This decode turns index format for a GeoServer StructuredGridCoverageReader into something
 * useful, giving access to the definition of the single attributes.
 * 
 * 

This is the XML REST representation: *

  {@code


  
    
      the_geom
      0
      1
      true
      com.vividsolutions.jts.geom.Polygon
    
    
      location
      0
      1
      true
      java.lang.String
    
    
      imageindex
      0
      1
      true
      java.lang.Integer
    
    
      time
      0
      1
      true
      java.sql.Timestamp
    
    
      elevation
      0
      1
      true
      java.lang.Double
    
    
      fileDate
      0
      1
      true
      java.sql.Timestamp
    
    
      updated
      0
      1
      true
      java.sql.Timestamp
    
  
  

}
* @author Simone Giannecchini, GeoSolutions SAS * */ public class RESTStructuredCoverageIndexSchema implements Iterable { private final List attributeList; /** * @param list */ @SuppressWarnings("unchecked") protected RESTStructuredCoverageIndexSchema(Element schema) { // check ordering of elements if(!schema.getName().equals("Schema")){ throw new IllegalStateException("Root element should be Schema"); } Element attributes = schema.getChild("attributes"); if(attributes==null){ throw new IllegalStateException("Root element should be Schema"); } List tmpList = new ArrayList(); for(Element el : (List)attributes.getChildren()){ tmpList.add(new RESTStructuredCoverageIndexAttribute(el)); } attributeList = Collections.unmodifiableList(tmpList); } public static RESTStructuredCoverageIndexSchema build(String response) { if(response == null) return null; Element pb = JDOMBuilder.buildElement(response); if(pb != null){ return new RESTStructuredCoverageIndexSchema(pb); } else { return null; } } public int size() { return attributeList.size(); } public boolean isEmpty() { return attributeList.isEmpty(); } public RESTStructuredCoverageIndexAttribute get(int index) { return attributeList.get(index); } /* (non-Javadoc) * @see java.lang.Iterable#iterator() */ @Override public Iterator iterator() { return attributeList.iterator(); } /** * Generic granule of the index. * *

This is the XML REST representation: *

  {@code
    
      the_geom
      0
      1
      true
      com.vividsolutions.jts.geom.Polygon
    
     * @author Simone Giannecchini, GeoSolutions SAS
     *
     */
    public static class RESTStructuredCoverageIndexAttribute {
        protected final Element attribute;

        public RESTStructuredCoverageIndexAttribute(Element elem) {
            this.attribute = elem;
        }

        public String getName() {
            return attribute.getChildTextTrim("name");
        }
        
        public String getMinOccurs() {
            return attribute.getChildTextTrim("minOccurs");
        }
        
        public String getMaxOccurs() {
            return attribute.getChildTextTrim("maxOccurs");
        }
        
        public String getNillable() {
            return attribute.getChildTextTrim("nillable");
        }
        
        public String getBinding() {
            return attribute.getChildTextTrim("binding");
        }

        @Override
        public String toString() {
            return "RESTStructuredCoverageGranule [getName()=" + getName()
                    + ", getMinOccurs()=" + getMinOccurs() + ", getMaxOccurs()=" + getMaxOccurs()
                    + ", getNillable()=" + getNillable() + ", getBinding()=" + getBinding() + "]";
        }
        
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy