Tabnine Logo
PrefixMapping
Code IndexAdd Tabnine to your IDE (free)

How to use
PrefixMapping
in
com.hp.hpl.jena.shared

Best Java code snippets using com.hp.hpl.jena.shared.PrefixMapping (Showing top 20 results out of 315)

origin: org.apache.clerezza.ext/org.apache.jena.jena-core

/**
 * Return a map of all the discovered prefixes
 */
public Map<String, String> getPrefixMap() {
  return prefixMapping.getNsPrefixMap();
}

origin: org.apache.clerezza.ext/org.apache.jena.jena-core

/**
 * Register a new prefix/namespace mapping which will be used to shorten
 * the print strings for resources in known namespaces.
 */
public static void registerPrefix(String prefix, String namespace) {
  prefixMapping.setNsPrefix( prefix, namespace );
}

origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

/** @see com.hp.hpl.jena.shared.PrefixMapping#getNsPrefixURI(java.lang.String) */
@Override
public String getNsPrefixURI(String prefix)
{
  String s = pmapLocal.getNsPrefixURI(prefix) ;
  if ( s != null )
    return s ;
  if ( pmapGlobal != null )
    return pmapGlobal.getNsPrefixURI(prefix) ;
  return null ;
}
origin: org.apache.clerezza.ext/org.apache.jena.jena-core

/**
 * Set the default prefix mappings.
 */
protected void setDefaultPrefixMappings() {
  m_prefixMap.setNsPrefixes( PrefixMapping.Standard );
  // PrefixMapping.Standard includes dc:, which OntModels traditionally haven't included
  m_prefixMap.removeNsPrefix( "dc" );
}
origin: com.hp.hpl.jena/arq

/** @see com.hp.hpl.jena.shared.PrefixMapping#removeNsPrefix(java.lang.String) */
public PrefixMapping removeNsPrefix(String prefix)
{
  pmapLocal.removeNsPrefix(prefix) ;
  if ( pmapGlobal != null && pmapGlobal.getNsPrefixURI(prefix) != null )
    throw new UnsupportedOperationException("PrefixMapping2: prefix '"+prefix+"' in the immutable map") ;
  return this ;
}
origin: org.apache.clerezza.ext/org.apache.jena.jena-arq

  @Override
  public boolean samePrefixMappingAs(PrefixMapping other)
  {
    if ( other == null )
      return false ;
    
    if ( other instanceof PrefixMapping2 )
    {
      PrefixMapping2 other2 = (PrefixMapping2)other ;
      
      return this.pmapGlobal.samePrefixMappingAs(other2.pmapGlobal) && 
          this.pmapLocal.samePrefixMappingAs(other2.pmapLocal) ;
    }
    
    // Do by map copy.
    return getNsPrefixMap().equals( other.getNsPrefixMap() );
  }
}
origin: com.hp.hpl.jena/sdb

@Test public void prefix2()
{
  PrefixMapping pmap = new PrefixMappingSDB(defaultPrefixURI, sdb) ;
  pmap.setNsPrefix("ex", "http://example/") ;
  assertNotNull(pmap.getNsPrefixURI("ex")) ;
}
 
origin: org.apache.clerezza.ext/org.apache.jena.jena-core

/**
 * Register a set of prefix to namespace mappings with the parser
 */
public void registerPrefixMap(Map<String, String> map) {
  prefixMapping.setNsPrefixes(map);
}

origin: com.hp.hpl.jena/sdb

  @Test public void prefix7()
  {
    String uri1 = "http://example/" ;
    String uri2 = "http://example/ns#" ;
    
    PrefixMapping pmap = new PrefixMappingSDB(defaultPrefixURI, sdb) ;
    pmap.setNsPrefix("ex1", uri1) ;
    pmap.setNsPrefix("ex2", uri2) ;
    assertEquals("ex2:foo", pmap.qnameFor("http://example/ns#foo")) ;
  }        
}
origin: epimorphics/elda

private PrefixMapping prefixes( APIResultSet rs ) {
  return PrefixMapping.Factory.create()
    .setNsPrefixes(rs.getMergedModel())
    .setNsPrefixes( PrefixMapping.Extended )
    .setNsPrefix( "terms", "http://purl.org/dc/terms/" )
    .setNsPrefix( "dum", "http://dummy/doc/schools" )
    .setNsPrefix( "dumx", "http://dummy//doc/schools" )
    ;
}

origin: com.hp.hpl.jena/arq

/** @see com.hp.hpl.jena.shared.PrefixMapping#getNsURIPrefix(java.lang.String) */
public String getNsURIPrefix(String uri)
{
  String s = pmapLocal.getNsURIPrefix(uri) ;
  if ( s != null )
    return s ;
  if ( pmapGlobal == null )
    return null ;
  if ( pmapGlobal != null )
    return pmapGlobal.getNsURIPrefix(uri) ;
  return null ;
}
origin: com.hp.hpl.jena/arq

  /** Use the prefix map to turn a URI into a qname, or return the original URI */
  
  public String shortForm(String uri)
  {
    return prefixMap.shortForm(uri) ;
  }
}
origin: org.apache.clerezza.ext/org.apache.jena.jena-core

/**
 * Expand qnames to URIs. If the given URI appears
 * to start with one of the registered prefixes then
 * expand the prefix, otherwise return the original URI
 */
public static String expandQname(String uri) {
  return prefixMapping.expandPrefix( uri );
}

origin: com.hp.hpl.jena/sdb

@Test public void prefix4()
{
  String uri = "http://example/" ;
  PrefixMapping pmap = new PrefixMappingSDB(defaultPrefixURI, sdb) ;
  pmap.setNsPrefix("ex", uri) ;
  
  assertEquals("ex", pmap.getNsURIPrefix("http://example/")) ;
}
   
origin: com.hp.hpl.jena/arq

private static String prefixFor(String uri, PrefixMapping mapping)
{
  if ( mapping == null ) return null ;
  
  String pname = mapping.shortForm(uri) ;
  if ( pname != uri && checkValidPrefixName(pname) )
    return pname ;
  pname = mapping.qnameFor(uri) ;
  if ( pname != null && checkValidPrefixName(pname) )
    return pname ;
  return null ;
}
 
origin: org.apache.clerezza.ext/org.apache.jena.jena-core

private static String myExpandPrefix(PrefixMapping prefixMapping, String qname)
{
  String s = prefixMapping.expandPrefix(qname) ;
  if ( s == null )
    return null ;
  if ( s.equals(qname) )
  {
    // The contract of expandPrefix is to return the original name if
    // there is no prefix but what s the expanded and original form are
    // actually the same character string ?
    int colon = qname.indexOf( ':' );
    if (colon < 0) 
      return null ;
    String prefix = qname.substring( 0, colon ) ;
    if ( prefixMapping.getNsPrefixURI(prefix) != null )
      // The original and resolved forms are the same.
      return s ;
    return null ;
  }
  return s ;
}

origin: com.hp.hpl.jena/arq

/** @see com.hp.hpl.jena.shared.PrefixMapping#qnameFor(java.lang.String) */
public String qnameFor(String uri)
{
  String s = pmapLocal.qnameFor(uri) ;
  if ( pmapGlobal == null )
    return s ;
  if ( s != null )
    return s ;
  if ( pmapGlobal != null )
    return pmapGlobal.qnameFor(uri) ;
  return null ;
}
origin: com.hp.hpl.jena/sdb

@Test public void prefix5()
{
  String uri = "http://example/" ;
  PrefixMapping pmap = new PrefixMappingSDB(defaultPrefixURI, sdb) ;
  pmap.setNsPrefix("ex", uri) ;
  
  assertEquals(uri+"foo", pmap.expandPrefix("ex:foo")) ;
}
origin: com.hp.hpl.jena/arq

  public boolean samePrefixMappingAs(PrefixMapping other)
  {
    if ( other == null )
      return false ;
    
    if ( ! ( other instanceof PrefixMapping2 ) )
      return false ;
    
    PrefixMapping2 other2 = (PrefixMapping2)other ;
    
    return this.pmapGlobal.samePrefixMappingAs(other2.pmapGlobal) && 
        this.pmapLocal.samePrefixMappingAs(other2.pmapLocal) ;
  }
}
origin: com.hp.hpl.jena/tdb

@Test public void multiple1()
{
  DatasetPrefixesTDB prefixes = DatasetPrefixesTDB.testing() ;
  PrefixMapping pmap1 = prefixes.getPrefixMapping() ;
  PrefixMapping pmap2 = prefixes.getPrefixMapping("http://graph/") ;
  pmap1.setNsPrefix("x", "http://foo/") ;
  assertNull(pmap2.getNsPrefixURI("x")) ;
  assertNotNull(pmap1.getNsPrefixURI("x")) ;
}
 
com.hp.hpl.jena.sharedPrefixMapping

Javadoc

Methods for recording namepsace prefix mappings and applying and unapplying them to URIs.

Note that a Model *is* a PrefixMapping, so all the PrefixMapping operations apply to Models, and a Model can be used to supply the PrefixMapping argument to setNsPrefixes.

Most used methods

  • getNsPrefixMap
    Return a copy of the internal mapping from names to URI strings. Updating this copy will have no eff
  • setNsPrefix
    Specify the prefix name for a URI prefix string. Any existing use of that prefix name is overwritten
  • getNsPrefixURI
    Get the URI bound to a specific prefix, null if there isn't one.
  • setNsPrefixes
    Copies the prefix mapping from other into this. Illegal prefix mappings are detected. Existing binds
  • getNsURIPrefix
    Answer the prefix for the given URI, or null if there isn't one. If there is more than one, one of t
  • qnameFor
    Answer a qname with the expansion of the given uri, or null if no such qname can be constructed usin
  • expandPrefix
    Expand the uri using the prefix mappings if possible. If prefixed has the form Foo:Bar, and Foo is a
  • samePrefixMappingAs
    Answer true iff this prefix-mappings are equal, that is, map the same prefixes to the same URIs; sam
  • shortForm
    Compress the URI using the prefix mappings if possible. If there is a prefix mapping Name -> URIStar
  • lock
    Lock the PrefixMapping so that changes can no longer be made to it. Primarily intended to lock Stand
  • removeNsPrefix
    Remove any existing maplet with the given prefix name and answer this mapping. If the prefix is the
  • withDefaultMappings
    Update this PrefixMapping with the bindings in map, only adding those (p, u) pairs for which neither
  • removeNsPrefix,
  • withDefaultMappings

Popular in Java

  • Start an intent from android
  • getResourceAsStream (ClassLoader)
  • getApplicationContext (Context)
  • setScale (BigDecimal)
  • Executor (java.util.concurrent)
    An object that executes submitted Runnable tasks. This interface provides a way of decoupling task s
  • Semaphore (java.util.concurrent)
    A counting semaphore. Conceptually, a semaphore maintains a set of permits. Each #acquire blocks if
  • ZipFile (java.util.zip)
    This class provides random read access to a zip file. You pay more to read the zip file's central di
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now