Protocol { public static Resource decodeContext(String encodedValue, ValueFactory valueFactory) { if (encodedValue == null) { return null; } else if (NULL_PARAM_VALUE.equals(encodedValue)) { return null; } else { Resource context = decodeResource(encodedValue, valueFactory); if (context instanceof Triple) { throw new IllegalArgumentException("Invalid context value: " + encodedValue); } return context; } }  static final String getProtocolLocation(String serverLocation); static final String getConfigLocation(String serverLocation); static final String getRepositoriesLocation(String serverLocation); static final String getRepositoryLocation(String serverLocation, String repositoryID); static final String getRepositoryConfigLocation(String repositoryLocation); static final String getStatementsLocation(String repositoryLocation); static final String getTransactionsLocation(String repositoryLocation); static final String getServerLocation(String repositoryLocation); static final String getRepositoryID(String repositoryLocation); static final String getContextsLocation(String repositoryLocation); static final String getNamespacesLocation(String repositoryLocation); static final String getNamespacePrefixLocation(String repositoryLocation, String prefix); static final String getSizeLocation(String repositoryLocation); static String encodeValue(Value value); static Value decodeValue(String encodedValue, ValueFactory valueFactory); static Resource decodeResource(String encodedValue, ValueFactory valueFactory); static IRI decodeURI(String encodedValue, ValueFactory valueFactory); static String encodeContext(Resource context); static Resource decodeContext(String encodedValue, ValueFactory valueFactory); static String[] encodeContexts(Resource... contexts); static Resource[] decodeContexts(String[] encodedValues, ValueFactory valueFactory); static final String CACHE_TIMEOUT_PROPERTY; final static int DEFAULT_TIMEOUT; static final String VERSION; static final String SUBJECT_PARAM_NAME; static final String PREDICATE_PARAM_NAME; static final String OBJECT_PARAM_NAME; static final String INCLUDE_INFERRED_PARAM_NAME; static final String CONTEXT_PARAM_NAME; static final String NULL_PARAM_VALUE; static final String GRAPH_PARAM_NAME; static final String UPDATE_PARAM_NAME; static final String BASEURI_PARAM_NAME; static final String QUERY_PARAM_NAME; static final String LIMIT_PARAM_NAME; static final String OFFSET_PARAM_NAME; static final String QUERY_LANGUAGE_PARAM_NAME; static final String TIMEOUT_PARAM_NAME; static final String REMOVE_GRAPH_PARAM_NAME; static final String INSERT_GRAPH_PARAM_NAME; static final String USING_GRAPH_PARAM_NAME; static final String USING_NAMED_GRAPH_PARAM_NAME; static final String DEFAULT_GRAPH_PARAM_NAME; static final String NAMED_GRAPH_PARAM_NAME; static final String ACCEPT_PARAM_NAME; @Deprecated
	static final String ISOLATION_LEVEL_PARAM_NAME; static final String TRANSACTION_SETTINGS_PREFIX; static final String ACTION_PARAM_NAME; static final String DISTINCT_PARAM_NAME; static final String PROTOCOL; static final String CONFIG; static final String REPOSITORIES; static final String STATEMENTS; static final String TRANSACTIONS; static final String CONTEXTS; static final String NAMESPACES; static final String BINDING_PREFIX; static final String SIZE; static final String TXN_MIME_TYPE; static final String FORM_MIME_TYPE; static final String SPARQL_QUERY_MIME_TYPE; static final String SPARQL_UPDATE_MIME_TYPE; static final String PRESERVE_BNODE_ID_PARAM_NAME; }
@Test public void testDecodeContext() { ValueFactory vf = SimpleValueFactory.getInstance(); assertEquals(vf.createBNode("bnode1"), Protocol.decodeContext("_:bnode1", vf)); assertEquals(vf.createIRI("urn:test"), Protocol.decodeContext("<urn:test>", vf)); try { Protocol.decodeContext("<<<urn:a> <urn:b> <urn:c>>>", SimpleValueFactory.getInstance()); fail("Must fail with exception"); } catch (IllegalArgumentException e) { } }