Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
source files from agraph32 install agsrc-3.2jar
  • Loading branch information
Mike Hinchey committed Nov 13, 2009
1 parent 95d0287 commit 754ad67
Show file tree
Hide file tree
Showing 161 changed files with 40,503 additions and 0 deletions.
456 changes: 456 additions & 0 deletions LICENSE.txt

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions overview.htm
@@ -0,0 +1,16 @@
<body>
A Java API to the AllegroGraph triple store implementation.
<p>
We provide adapters for Sesame 2.x and Jena 2.5.
<h3>Compatibility Note</h3>
This Java API is similar to the AllegroGraph Java API in earlier releases (3.1.1 and older),
but it is significantly different in many details. Existing Java programs will need to be
modified substantially.
<ul>
<li>The primary public package is <code>com.franz.agbase</code>
<li>New classes: ValueSetIterator, PrologSelectQuery
<li>All the methods in AllegroGraph for making Prolog queries have been
eliminated in favor of the PrologSelectQuery class.
<li>The ValueObject class hierarchy is completely separate form Sesame classes.
</ul>
</body>
3 changes: 3 additions & 0 deletions src/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Created-By: 1.5.0 (Sun Microsystems Inc.)

76 changes: 76 additions & 0 deletions src/com/franz/ag/AllegroGraphException.java
@@ -0,0 +1,76 @@

//***** BEGIN LICENSE BLOCK *****
//Version: MPL 1.1
//
//The contents of this file are subject to the Mozilla Public License Version
//1.1 (the "License"); you may not use this file except in compliance with
//the License. You may obtain a copy of the License at
//http://www.mozilla.org/MPL/
//
//Software distributed under the License is distributed on an "AS IS" basis,
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
//for the specific language governing rights and limitations under the
//License.
//
//The Original Code is the AllegroGraph Java Client interface.
//
//The Original Code was written by Franz Inc.
//Copyright (C) 2006 Franz Inc. All Rights Reserved.
//
//***** END LICENSE BLOCK *****

/*
* Created on Jun 30, 2006
*
*/
package com.franz.ag;


/**
* AllegroGraph exceptions.
*
* @author mm
*
*/
public class AllegroGraphException extends Exception {

//FIXME
// THIS CLASS CAN BE ELIMINATED by merging down to the subclass
// in com.franz.agbase when com.franz.ag package is discarded.

/**
*
*/
private static final long serialVersionUID = -1311774930268277268L;

/**
*
*/
public AllegroGraphException() {
super();
}

/**
* @param arg0
*/
public AllegroGraphException(String arg0) {
super(arg0);

}

/**
* @param arg0
* @param arg1
*/
public AllegroGraphException(String arg0, Throwable arg1) {
super(arg0, arg1);
}

/**
* @param arg0
*/
public AllegroGraphException(Throwable arg0) {
super(arg0);
}

}
190 changes: 190 additions & 0 deletions src/com/franz/ag/NamespaceRegistry.java
@@ -0,0 +1,190 @@
package com.franz.ag;

import java.util.ArrayList;


/**
* Instances of this class define mappings from prefixes or abbreviations to full
* URI fragments.
*
* @author mm
*
*/
public class NamespaceRegistry {

//FIXME
// THIS CLASS CAN BE ELIMINATED by merging down to the subclass
// in com.franz.agbase when com.franz.ag package is discarded.
//
// Since the constructors in package ag are public, we cannot ensure that
// all instances are agbase instances. Therefore, make sure that all declarations
// in agbase code refer to the ag.NamespaceRegistry declaration.


private ArrayList<Object> regs = new ArrayList<Object>();

/**
* Create a new empty NamaspaceRegistry instance.
*
*/
public NamespaceRegistry () {}

/**
* Create a new NamaspaceRegistry instance containing the same definitions
* as another.
* @param ns the NamaspaceRegistry instance from which definitions are copied.
*/
public NamespaceRegistry ( NamespaceRegistry ns ) {
register(ns);
}

/**
* Create a new NamaspaceRegistry instance containing the definitions
* specified in an array of strings.
* @param defs an array of alternating prefix and fragment strings.
*/
public NamespaceRegistry ( String[] defs ) {
register(defs);
}




private static final String[] preDefs = new String[] {
"rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"rdfs", "http://www.w3.org/2000/01/rdf-schema#",
"owl", "http://www.w3.org/2002/07/owl#"
};

/**
* A pre-defined namespace registry with three definitions:
* <pre>
* {
* "rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
* "rdfs", "http://www.w3.org/2000/01/rdf-schema#",
* "owl", "http://www.w3.org/2002/07/owl#"
* }
* </pre>
*/
public static final NamespaceRegistry RDFandOwl = new com.franz.agbase.NamespaceRegistry(preDefs);


// register(prefix, uri) - add entry to collection or rplace
// existing entry
// if uri is null, delete the entry
// clear() - delete all entries
// getPrefixes() -> array of prefixes
// getURI(prefix) -> uri string

/**
* Add one prefix definition to this instance.
* @param prefix the prefix string
* @param uri the associated URI fragment
*/
public void register ( String prefix, String uri ) {
boolean found = false;
find:
for (int i = 0; i < regs.size(); i=i+2) {
String e = (String) regs.get(i);
if ( e.equals(prefix) )
{
if ( uri==null )
{
regs.remove(i); regs.remove(i);
}
else
regs.set(i+1, uri);
found = true;
break find;
}
}
if ( !found )
{
regs.add(prefix); regs.add(uri);
}
}

/**
* Add all the definitions in some other instance to this one.
* @param moreDefs the source instance
*/
public void register ( NamespaceRegistry moreDefs ) {
ArrayList<Object> defs = moreDefs.regs;
for (int i = 0; i < defs.size(); i=i+2) {
register((String)defs.get(i), (String)defs.get(i+1));
}
}

/**
* Add all the definitions in an array to this instance.
* @param moreDefs and alternating array of prefix strings and URI fragments
*/
public void register ( String[] moreDefs ) {
for (int i = 0; i < moreDefs.length; i=i+2)
register(moreDefs[i], moreDefs[i+1]);
}


/**
* Query the URI fragment associated with some prefix.
* @param prefix the prefix string
* @return the URI fragment
* @throws UndefinedPrefix
*/
public String getURI ( String prefix ) throws UndefinedPrefix {
for (int i = 0; i < regs.size(); i=i+2) {
String e = (String) regs.get(i);
if ( e.equals(prefix) )
return (String) regs.get(i+1);
}
throw new UndefinedPrefix();
}

public static class UndefinedPrefix extends AllegroGraphException {

/**
*
*/
private static final long serialVersionUID = -3244320712290446205L;

}

/**
* Query the prefixes defined in this instance.
* @return an array of the prefixes.
*/
public String[] getPrefixes () {
String[] prefixes = new String[(regs.size())/2];
for (int i = 0; i < prefixes.length; i++) {
prefixes[i] = (String) regs.get(2*i);
}
return prefixes;
}

/**
* Discard all the definitions in this instance.
*
*/
public void clear () {
regs = new ArrayList<Object>();
}

/**
* Convert a namespace registry to an array of strings.
* @return an array of alternating abbreviation and URI strings
*/
public String[] toArray () {
String[] out = new String[regs.size()];
for (int i = 0; i < out.length; i++) {
out[i] = (String) regs.get(i);
}
return out;
}

public com.franz.agbase.NamespaceRegistry promote () {
if ( this instanceof com.franz.agbase.NamespaceRegistry )
return (com.franz.agbase.NamespaceRegistry) this;
return new com.franz.agbase.NamespaceRegistry(this);
}

}
32 changes: 32 additions & 0 deletions src/com/franz/ag/UPI.java
@@ -0,0 +1,32 @@
package com.franz.ag;

/**
* This interface defines instances of Universal Part Identifiers.
* UPIs are used to denote nodes and literals in AllegroGraph.
* They are returned as values of queries or accessors, and may be used
* as arguments to queries and accessors. In general, UPI references
* are more efficient than string references.
*
* <p>
* UPIs are discussed in more detail in the AllegroGraph Introduction.
*
* @author mm
*
*/
public interface UPI {

//FIXME
//TODO - when ag package is discarded, this interface can be moved to
// the agbase package after the sub-interface is deleted.
// Any code outside these internal modules can already mention
// agbase.UPI and will work without change after the move.
//
// Any instance can be cast to agbase.UPI because the only constructor is in agbase.

public boolean equals(Object x);

public int hashCode();

public String toString();

}
12 changes: 12 additions & 0 deletions src/com/franz/ag/package.html
@@ -0,0 +1,12 @@
<html>
<head></head>
<body>
Java API to the AllegroGraph implementation.
<p>

The classes and interfaces in this package provide access
to the native features and capabilites of AllegroGraph.


</body>
</html>

0 comments on commit 754ad67

Please sign in to comment.