/** * returns the value asociated with <code>key</code> on the set of key/value pairs of this * request reader * * @param key DOCUMENT ME! * @return DOCUMENT ME! */ protected String getValue(String key) { return Converters.convert(kvpPairs.get(key), String.class); }
public <T> T get(String key, Class<T> clazz) { Object obj = get(key); if (obj == null) { return null; } return Converters.convert(obj, clazz); }
/** Parses the string into a numberic value. */ public Object parse(String value) throws Exception { return Converters.convert(value, getBinding()); } }
@SuppressWarnings("unchecked") @Override public <T> T get(Object object, String xpath, Class<T> target) throws IllegalArgumentException { Object value = getProperty(object, xpath); T result; if (null != target && null != value) { result = Converters.convert(value, target); } else { result = (T) value; } return result; }
public void imprt(File dir) throws Exception { LegacyServicesReader reader = reader(dir); Map<String, Object> global = reader.global(); configFileName = (String) global.get("log4jConfigFile"); logFile = (String) global.get("logLocation"); suppressStdOutLogging = Converters.convert(global.get("suppressStdOutLogging"), Boolean.class); }
@Override public <T> T evaluate(Object object, Class<T> context) { // Selection of the first expression Expression clazzExpression = parameters.get(0); // Getting the defined class Class clazz = clazzExpression.evaluate(object, Class.class); // Checking the result boolean result = false; // If the input class is Object, the function always returns true if (clazz != null) { if (clazz == Object.class) { result = true; } else { // Otherwise the function checks if the class is an instance of the // input class result = clazz.isAssignableFrom(object.getClass()); } } // Finally the result is converted to the defined context class return Converters.convert(result, context); }
protected void parseParameters() { if (myParameterMap != null) return; String contentType = myWrappedRequest.getContentType(); if (myWrappedRequest.getMethod().equals("POST") && contentType != null && contentType.startsWith("application/x-www-form-urlencoded")) { parseFormBody(); } else { myParameterMap = new HashMap(super.getParameterMap()); for (Object key : myParameterMap.keySet()) { Object value = myParameterMap.get(key); if (value instanceof String[]) { myParameterMap.put(key, Arrays.asList(((String[]) value))); } else if (!(value instanceof List)) { myParameterMap.put(key, Converters.convert(value, List.class)); } } } }
public Collection<Object> convertDimensionValue(String name, String value) { List<Object> result = new ArrayList<Object>(); try { String typeName = getDomainDatatype(name); if (typeName != null) { Class<?> type = Class.forName(typeName); if (type == java.util.Date.class) { result.addAll(new TimeParser().parse(value)); } else if (Number.class.isAssignableFrom(type) && !value.contains(",")) { result.add(parseNumberOrRange(value)); } else { for (String element : value.split(",")) { result.add(Converters.convert(element, type)); } } } else { result.add(value); } } catch (Exception e) { LOGGER.log(Level.WARNING, "Failed to convert dimension value: ", e); result.add(value); } return result; }
Object converted = Converters.convert(value, target); if (converted != null) { value = converted;
value = params.get(key); if (value != null) { Object converted = Converters.convert(value, target); if (converted == null) { throw new RuntimeException(
String complexTypeId = getComplexTypeId(value.getClass()); if (complexTypeId == null) { String str = Converters.convert(value, String.class); if (str == null) { str = value.toString();
public void modifyFeatures(AttributeDescriptor[] type, Object[] values, Filter filter) throws IOException { SimpleFeatureType original = typeMap.getOriginalFeatureType(); // map back attribute types and values to the original values AttributeDescriptor[] originalTypes = new AttributeDescriptor[type.length]; Object[] originalValues = new Object[values.length]; for (int i = 0; i < values.length; i++) { originalTypes[i] = original.getDescriptor(type[i].getName()); if (values[i] != null) { Class<?> target = originalTypes[i].getType().getBinding(); originalValues[i] = Converters.convert(values[i], target); if (originalValues[i] == null) throw new IOException("Could not map back " + values[i] + " to type " + target); } } featureStore() .modifyFeatures(originalTypes, originalValues, store.retypeFilter(filter, typeMap)); }
type = geomType == null ? Geometry.class : geomType.getBinding(); } else if (reader.getNodeName().equals("srid")) { srid = Converters.convert(reader.getValue(), Integer.class);
final List<?> value = extractValue(p); for (Object o : value) { final String s = Converters.convert(o, String.class); for (String filename : this.dataDirectory.list()) { if (isDataFile(filename)) {
/** * Default implementation delegates handling of context conversion to Converters utility class. * * <p>Subclasses are expected to make use of the {@linkplain Converters} utility class (as the * easiest way to provide value morphing in conformance with the Filter specification). */ public <T> T evaluate(Object object, Class<T> context) { return Converters.convert(evaluate(object), context); } }
public Object convert(Object source, Class target) throws Exception { if (source instanceof GeometryAttribute) { return Converters.convert(((GeometryAttribute) source).getValue(), target); } return null; } };
public Object convert(Object source, Class target) { if (source instanceof Attribute) { // get the attribute value Attribute attribute = (Attribute) source; Object value = attribute.getValue(); // let the available converters do their job return Converters.convert(value, target); } // this should not happen, anyway we can only handle attributes return null; } };
public ColorMapEntryBuilder colorHex(String hex) { Color color = Converters.convert(hex, Color.class); if (color == null) { throw new IllegalArgumentException( "The provided expression could not be turned into a color: " + hex); } return color(color); }
public FillBuilder colorHex(String hex) { Color color = Converters.convert(hex, Color.class); if (color == null) { throw new IllegalArgumentException( "The provided expression could not be turned into a color: " + hex); } return color(color); }
public boolean evaluate(Object feature) { Geometry other = Converters.convert(property.evaluate(feature), Geometry.class); if (other == null) return false; return get3DEnvelope(other).intersects(envelope); }