protected URI getDefaultURI() { URIFactory<T, P> factory = getFactory(); if (factory == null) { return null; } else { return factory.getDefaultURI(); } }
/** * Given a Key / Value mapping create and append a URI query value that represents the mapped entries, return the * newly updated URI that contains the value of the given URI and the appended query value. * * @param uri The source URI that will have the Map entries appended as a URI query value. * @param queryParameters The Key / Value mapping that will be transformed into a URI query string. * @return A new URI value that combines the given URI and the constructed query string. * @throws java.net.URISyntaxException */ public static URI applyParameters(URI uri, Map<String, String> queryParameters) throws URISyntaxException { return applyParameters(uri, queryParameters, ""); }
/** * Removes any URI query from the given uri and return a new URI that does not contain the query portion. * * @param uri The URI whose query value is to be removed. * @return a new URI that does not contain a query value. * @throws java.net.URISyntaxException */ public static URI removeQuery(URI uri) throws URISyntaxException { return createURIWithQuery(uri, null); }
public void populateObject(URI uri, T bean) throws Exception { BeanSupport.setData(uri, bean, parseQuery(uri.getQuery(), null)); }
/** * Given a composite URI, parse the individual URI elements contained within that URI and return * a CompositeData instance that contains the parsed URI values. * * @param uri The target URI that should be parsed. * @return a new CompositeData instance representing the parsed composite URI. * @throws java.net.URISyntaxException */ public static CompositeData parseComposite(URI uri) throws URISyntaxException { CompositeData rc = new CompositeData(); rc.scheme = uri.getScheme(); String ssp = stripPrefix(uri.getRawSchemeSpecificPart().trim(), "//").trim(); parseComposite(uri, rc, ssp); rc.fragment = uri.getFragment(); return rc; }
protected ConnectionOptions newConnectionOptions(URI uri, Map<String, String> query) throws Exception { return BeanSupport.setData(uri, new ConnectionOptions(), query); } }
/** * This is the default implementation. * Sub classes are should provide a proper implementation for their schemas. */ protected URI internalNewURI(T bean) throws Exception { String query = BeanSupport.getData(null, bean); return new URI(getSchemaName(), null, "//", query, null); }
/** * It will create a new Object for the URI selected schema. * the propertyOverrides is used to replace whatever was defined on the URL string * * @param uri The URI * @param propertyOverrides used to replace whatever was defined on the URL string * @return new Object * @throws Exception On error */ public T newObject(URI uri, Map<String, String> propertyOverrides, P param) throws Exception { return internalNewObject(uri, parseQuery(uri.getQuery(), propertyOverrides), param); }
public void registerSchema(URISchema<T, P> schemaFactory) { schemas.put(schemaFactory.getSchemaName(), schemaFactory); schemaFactory.setFactory(this); }
public static boolean isParameterised(String address) { return URISupport.containsQuery(address); }
public URI expandURI(String uriString) throws Exception { return normalise(uriString); }
public T newObject(URI uri, P param) throws Exception { return newObject(uri, null, param); }
public URI newURI(T bean) throws Exception { return internalNewURI(bean); }
private PropertyDescriptor createFluentPropertyDescritor(Method m, String propertyName) throws IntrospectionException { return new PropertyDescriptor(propertyName(m), null, m); }
public T newObject(String uri, P param) throws Exception { return newObject(new URI(uri), param); }
public void populateObject(String uri, T bean) throws Exception { populateObject(new URI(uri), bean); }
public URI createSchema(String scheme, T bean) throws Exception { URISchema<T, P> schemaFactory = schemas.get(scheme); if (schemaFactory == null) { throw new NullPointerException("Schema " + scheme + " not found"); } return schemaFactory.newURI(bean); }
public static String toParameterisedAddress(String address, Map<String, String> parameters) throws URISyntaxException { if (parameters != null && !parameters.isEmpty()) { return appendParameters(new StringBuilder(address), parameters).toString(); } else { return address; } }
protected int getPort(URI uri) { URI defaultFactory = getDefaultURI(); if (defaultFactory != null && uri.getPort() < 0 && defaultFactory.getScheme().equals(uri.getScheme())) { uri = defaultFactory; } return uri.getPort(); }
public static boolean isParameterised(SimpleString address) { return URISupport.containsQuery(address); }