UriManager.java :  » RSS-RDF » sesame » org » openrdf » sail » rdbms » managers » Java Open Source

Java Open Source » RSS RDF » sesame 
sesame » org » openrdf » sail » rdbms » managers » UriManager.java
/*
 * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
 *
 * Licensed under the Aduna BSD-style license.
 */
package org.openrdf.sail.rdbms.managers;

import java.sql.SQLException;

import org.openrdf.sail.rdbms.managers.base.ValueManagerBase;
import org.openrdf.sail.rdbms.model.RdbmsURI;
import org.openrdf.sail.rdbms.schema.URITable;

/**
 * Manages URIs. Including creating, inserting, and looking up their
 * IDs.
 * 
 * @author James Leigh
 * 
 */
public class UriManager extends ValueManagerBase<RdbmsURI> {
  public static UriManager instance;
  private URITable table;

  public UriManager() {
    instance = this;
  }

  public void setUriTable(URITable shorter) {
    this.table = shorter;
  }

  @Override
  public void close()
    throws SQLException
  {
    super.close();
    table.close();
  }

  @Override
  protected boolean expungeRemovedStatements(int count, String condition)
    throws SQLException
  {
    return table.expungeRemovedStatements(count, condition);
  }

  @Override
  protected int getBatchSize() {
    return table.getBatchSize();
  }

  @Override
  protected String key(RdbmsURI value) {
    return value.stringValue();
  }

  @Override
  protected void insert(Number id, RdbmsURI resource) throws SQLException, InterruptedException {
    String uri = resource.stringValue();
    if (getIdSequence().isLong(id)) {
      table.insertLong(id, uri);
    } else {
      table.insertShort(id, uri);
    }
  }

  @Override
  protected void optimize() throws SQLException {
    super.optimize();
    table.optimize();
  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.