@Override public Double unencode (String value) throws ConfigurationException { try { return Double.parseDouble(value); } catch (NumberFormatException e) { throw new ConfigurationException("Unparsable double value "+value, e); } }
@Override public T unencode (String value) throws ConfigurationException { try { return _type.cast(_valueOf.invoke(null, value)); } catch (IllegalAccessException e) { throw new ConfigurationException("Attempt to get inaccessible value "+value, e); } catch (IllegalArgumentException e) { throw new ConfigurationException("enum.valueOf somehow takes a non-string", e); } catch (InvocationTargetException e) { throw new ConfigurationException("enum.valueOf is impossibly non-static!", e); } }
@Override public Boolean unencode (String value) throws ConfigurationException { try { return Boolean.valueOf(value); } catch (NumberFormatException e) { throw new ConfigurationException("Unparsable boolean value "+value, e); } }
@Override public Integer unencode (String value) throws ConfigurationException { try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ConfigurationException("Unparsable int value "+value, e); } }
@Override public UUID unencode (String value) throws ConfigurationException { try { String[] parts = value.split(":"); long msb = Long.parseLong(parts[0], 16); long lsb = Long.parseLong(parts[1], 16); return new UUID(msb, lsb); } catch (NullPointerException|NumberFormatException|ArrayIndexOutOfBoundsException e) { throw new ConfigurationException("Error parsing stored UUID", e); } }
@Override public void readConfiguration (JSONObject rootNode) throws ConfigurationException { super.readConfiguration(rootNode); gradients.clear(); try { readGradients(getPropertyValue(GRADIENTS), gradients); } catch (JSONException e) { throw new ConfigurationException("Error configuring factory "+ this.getClass().getName(), e); } }
@Override protected PyramidIO create() throws ConfigurationException { try { String rootPath = getPropertyValue(ROOT_PATH); return new SQLitePyramidIO(rootPath); } catch (ClassNotFoundException | SQLException e) { throw new ConfigurationException("Error creating SQLite pyramid IO", e); } } }
/** * Initialize needed construction values from a properties list. * * @param rootNode The root node of all configuration information for this * factory. * @throws ConfigurationException If something goes wrong in configuration. */ public void readConfiguration (JSONObject rootNode) throws ConfigurationException { try { _configurationNode = getConfigurationNode(rootNode); for (ConfigurableFactory<?> child: _children) { child.readConfiguration(rootNode); } _configured = true; } catch (JSONException e) { throw new ConfigurationException("Error configuring factory "+this.getClass().getName(), e); } }
/** * All this method does is check the return type of a serializer * programatically, As such, it supercedes the warnings hidden here. * * It will only work, of course, if the serializer is set up correctly * (i.e., without lying about its type_, and if the pass-ed class and * expandedClass actually match; mis-use will, of course, cause errors. */ @SuppressWarnings({"unchecked", "rawtypes"}) public static <T> TileSerializer<T> checkBinClass (TileSerializer<?> serializer, Class<T> expectedBinClass, TypeDescriptor expandedExpectedBinClass) throws ConfigurationException { if (null == serializer) { throw new ConfigurationException("No serializer given for renderer"); } if ( !expandedExpectedBinClass.equals(serializer.getBinTypeDescription()) && !serializerTypeCompatibleToNumber( serializer, expandedExpectedBinClass )) { throw new ConfigurationException("Serialization type does not match rendering type. Serialization class was "+serializer.getBinTypeDescription()+", renderer type was "+expandedExpectedBinClass); } return (TileSerializer) serializer; }
@Override protected PyramidIO create() throws ConfigurationException { try { String driver = getPropertyValue(JDBC_DRIVER); String rootPath = getPropertyValue(ROOT_PATH); return new JDBCPyramidIO(driver, rootPath); } catch (ClassNotFoundException | SQLException e) { throw new ConfigurationException("Error creating JDBCPyramidIO", e); } } }
@Override protected TilePyramid create () throws ConfigurationException { String pyramidType = getPropertyValue(PYRAMID_TYPE).toLowerCase(); if ("webmercator".equals(pyramidType) || "epsg:900913".equals(pyramidType) || "epsg:3857".equals(pyramidType)) { return new WebMercatorTilePyramid(); } else if ("areaofinterest".equals(pyramidType) || "epsg:4326".equals(pyramidType)) { double minX = getPropertyValue(MINIMUM_X); double maxX = getPropertyValue(MAXIMUM_X); double minY = getPropertyValue(MINIMUM_Y); double maxY = getPropertyValue(MAXIMUM_Y); return new AOITilePyramid(minX, minY, maxX, maxY); } else { throw new ConfigurationException("Unrecognized pyramid type "+pyramidType); } } }
throw new ConfigurationException("Attempt to get value from uninitialized factory");
@Override protected PyramidIO createInstance () throws ConfigurationException { try { String quorum = getPropertyValue(HBASE_ZOOKEEPER_QUORUM); String port = getPropertyValue(HBASE_ZOKEEPER_PORT); String master = getPropertyValue(HBASE_MASTER); return new HBasePyramidIO(quorum, port, master); } catch (IOException e) { throw new ConfigurationException("Exception creating HBase pyramid IO", e); } } }
@Override protected PyramidIO createInstance () throws ConfigurationException { try { String quorum = getPropertyValue(HBasePyramidIOFactory.HBASE_ZOOKEEPER_QUORUM); String port = getPropertyValue(HBasePyramidIOFactory.HBASE_ZOKEEPER_PORT); String master = getPropertyValue(HBasePyramidIOFactory.HBASE_MASTER); return new HBaseSlicedPyramidIO(quorum, port, master); } catch (IOException e) { throw new ConfigurationException("Error creating HBase sliced pyramid IO", e); } } }
/** * Get the value read at configuration time for the given property. * * The behavior of this function is undefined if called before * readConfiguration (either version). */ public <PT> PT getPropertyValue (ConfigurationProperty<PT> property) throws ConfigurationException { // if a value has not been configured for this property, return default if ( !hasPropertyValue( property ) ) { PT defaultValue = getDefaultValue(property); LOGGER.warn("Property {} unset. Using default {}.", getFullPropertyName(property), defaultValue); return defaultValue; } try { return property.unencodeJSON( new JSONNode( getPropertyNode( property ) , property.getName() ) ); } catch (JSONException e) { // Must not have been there. Ignore, leaving as default. throw new ConfigurationException("Error reading property "+getFullPropertyName(property)+" from configuration "+_configurationNode); } }