Permalink
Browse files

fix DOS EOLs

  • Loading branch information...
1 parent 040eb09 commit 82335a6b87144ce3259ae87262d584954f9d212e Kevin Layer committed Jul 2, 2009
View
30 httpdsail/.classpath
@@ -1,15 +1,15 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="lib" path="openrdf-sesame-2.2-onejar.jar"/>
- <classpathentry kind="lib" path="slf4j-api-1.4.3.jar"/>
- <classpathentry kind="lib" path="slf4j-log4j12-1.4.3.jar"/>
- <classpathentry kind="lib" path="json.jar"/>
- <classpathentry kind="lib" path="commons-httpclient-3.0.1.jar"/>
- <classpathentry kind="lib" path="commons-logging-1.0.4.jar"/>
- <classpathentry kind="lib" path="commons-codec-1.3.jar"/>
- <classpathentry kind="lib" path="log4j-1.2.11.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="lib" path="openrdf-sesame-2.2-onejar.jar"/>
+ <classpathentry kind="lib" path="slf4j-api-1.4.3.jar"/>
+ <classpathentry kind="lib" path="slf4j-log4j12-1.4.3.jar"/>
+ <classpathentry kind="lib" path="json.jar"/>
+ <classpathentry kind="lib" path="commons-httpclient-3.0.1.jar"/>
+ <classpathentry kind="lib" path="commons-logging-1.0.4.jar"/>
+ <classpathentry kind="lib" path="commons-codec-1.3.jar"/>
+ <classpathentry kind="lib" path="log4j-1.2.11.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
View
132 httpdsail/src/org/openrdf/model/impl/BooleanLiteralImpl.java
@@ -1,66 +1,66 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.model.impl;
-
-import org.openrdf.model.vocabulary.XMLSchema;
-
-/**
- * An extension of {@link LiteralImpl} that stores a boolean value to avoid
- * parsing.
- *
- * @author David Huynh
- * @author Arjohn Kampman
- */
-public class BooleanLiteralImpl extends LiteralImpl {
-
- /*-----------*
- * Constants *
- *-----------*/
-
- private static final long serialVersionUID = -3610638093719366795L;
-
- public static final BooleanLiteralImpl TRUE = new BooleanLiteralImpl(true);
-
- public static final BooleanLiteralImpl FALSE = new BooleanLiteralImpl(false);
-
- /*-----------*
- * Variables *
- *-----------*/
-
- private boolean value;
-
- /*--------------*
- * Constructors *
- *--------------*/
-
- /**
- * Creates an xsd:boolean typed literal with the specified value.
- */
- public BooleanLiteralImpl(boolean value) {
- super(Boolean.toString(value), XMLSchema.BOOLEAN);
- this.value = value;
- }
-
- /*---------*
- * Methods *
- *---------*/
-
- @Override
- public boolean booleanValue()
- {
- return value;
- }
-
- /**
- * Returns a {@link BooleanLiteralImpl} for the specified value. This method
- * uses the constants {@link #TRUE} and {@link #FALSE} as result values,
- * preventing the often unnecessary creation of new
- * {@link BooleanLiteralImpl} objects.
- */
- public static BooleanLiteralImpl valueOf(boolean value) {
- return value ? TRUE : FALSE;
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.model.impl;
+
+import org.openrdf.model.vocabulary.XMLSchema;
+
+/**
+ * An extension of {@link LiteralImpl} that stores a boolean value to avoid
+ * parsing.
+ *
+ * @author David Huynh
+ * @author Arjohn Kampman
+ */
+public class BooleanLiteralImpl extends LiteralImpl {
+
+ /*-----------*
+ * Constants *
+ *-----------*/
+
+ private static final long serialVersionUID = -3610638093719366795L;
+
+ public static final BooleanLiteralImpl TRUE = new BooleanLiteralImpl(true);
+
+ public static final BooleanLiteralImpl FALSE = new BooleanLiteralImpl(false);
+
+ /*-----------*
+ * Variables *
+ *-----------*/
+
+ private boolean value;
+
+ /*--------------*
+ * Constructors *
+ *--------------*/
+
+ /**
+ * Creates an xsd:boolean typed literal with the specified value.
+ */
+ public BooleanLiteralImpl(boolean value) {
+ super(Boolean.toString(value), XMLSchema.BOOLEAN);
+ this.value = value;
+ }
+
+ /*---------*
+ * Methods *
+ *---------*/
+
+ @Override
+ public boolean booleanValue()
+ {
+ return value;
+ }
+
+ /**
+ * Returns a {@link BooleanLiteralImpl} for the specified value. This method
+ * uses the constants {@link #TRUE} and {@link #FALSE} as result values,
+ * preventing the often unnecessary creation of new
+ * {@link BooleanLiteralImpl} objects.
+ */
+ public static BooleanLiteralImpl valueOf(boolean value) {
+ return value ? TRUE : FALSE;
+ }
+}
View
78 httpdsail/src/org/openrdf/model/impl/CalendarLiteralImpl.java
@@ -1,39 +1,39 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.model.impl;
-
-import javax.xml.datatype.XMLGregorianCalendar;
-
-import org.openrdf.model.datatypes.XMLDatatypeUtil;
-
-/**
- * An extension of {@link LiteralImpl} that stores a calendar value to avoid
- * parsing.
- *
- * @author David Huynh
- * @author Arjohn Kampman
- */
-public class CalendarLiteralImpl extends LiteralImpl {
-
- private static final long serialVersionUID = -8959671333074894312L;
-
- private final XMLGregorianCalendar calendar;
-
- /**
- * Creates a literal for the specified calendar using a datatype appropriate
- * for the value indicated by {@link XMLGregorianCalendar#getXMLSchemaType()}.
- */
- public CalendarLiteralImpl(XMLGregorianCalendar calendar) {
- super(calendar.toXMLFormat(), XMLDatatypeUtil.qnameToURI(calendar.getXMLSchemaType()));
- this.calendar = calendar;
- }
-
- @Override
- public XMLGregorianCalendar calendarValue()
- {
- return calendar;
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.model.impl;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.openrdf.model.datatypes.XMLDatatypeUtil;
+
+/**
+ * An extension of {@link LiteralImpl} that stores a calendar value to avoid
+ * parsing.
+ *
+ * @author David Huynh
+ * @author Arjohn Kampman
+ */
+public class CalendarLiteralImpl extends LiteralImpl {
+
+ private static final long serialVersionUID = -8959671333074894312L;
+
+ private final XMLGregorianCalendar calendar;
+
+ /**
+ * Creates a literal for the specified calendar using a datatype appropriate
+ * for the value indicated by {@link XMLGregorianCalendar#getXMLSchemaType()}.
+ */
+ public CalendarLiteralImpl(XMLGregorianCalendar calendar) {
+ super(calendar.toXMLFormat(), XMLDatatypeUtil.qnameToURI(calendar.getXMLSchemaType()));
+ this.calendar = calendar;
+ }
+
+ @Override
+ public XMLGregorianCalendar calendarValue()
+ {
+ return calendar;
+ }
+}
View
178 httpdsail/src/org/openrdf/model/impl/DecimalLiteralImpl.java
@@ -1,89 +1,89 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.model.impl;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.openrdf.model.URI;
-import org.openrdf.model.vocabulary.XMLSchema;
-
-/**
- * An extension of {@link LiteralImpl} that stores an integer value using a
- * {@link BigDecimal} object.
- *
- * @author Arjohn Kampman
- */
-public class DecimalLiteralImpl extends LiteralImpl {
-
- private static final long serialVersionUID = -3310213093222314380L;
-
- private final BigDecimal value;
-
- /**
- * Creates an xsd:decimal literal with the specified value.
- */
- public DecimalLiteralImpl(BigDecimal value) {
- this(value, XMLSchema.DECIMAL);
- }
-
- /**
- * Creates a literal with the specified value and datatype.
- */
- public DecimalLiteralImpl(BigDecimal value, URI datatype) {
- // TODO: maybe DecimalLiteralImpl should not extend LiteralImpl?
- super(value.toPlainString(), datatype);
- this.value = value;
- }
-
- @Override
- public byte byteValue()
- {
- return value.byteValue();
- }
-
- @Override
- public short shortValue()
- {
- return value.shortValue();
- }
-
- @Override
- public int intValue()
- {
- return value.intValue();
- }
-
- @Override
- public long longValue()
- {
- return value.longValue();
- }
-
- @Override
- public float floatValue()
- {
- return value.floatValue();
- }
-
- @Override
- public double doubleValue()
- {
- return value.doubleValue();
- }
-
- @Override
- public BigInteger integerValue()
- {
- return value.toBigInteger();
- }
-
- @Override
- public BigDecimal decimalValue()
- {
- return value;
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.model.impl;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.vocabulary.XMLSchema;
+
+/**
+ * An extension of {@link LiteralImpl} that stores an integer value using a
+ * {@link BigDecimal} object.
+ *
+ * @author Arjohn Kampman
+ */
+public class DecimalLiteralImpl extends LiteralImpl {
+
+ private static final long serialVersionUID = -3310213093222314380L;
+
+ private final BigDecimal value;
+
+ /**
+ * Creates an xsd:decimal literal with the specified value.
+ */
+ public DecimalLiteralImpl(BigDecimal value) {
+ this(value, XMLSchema.DECIMAL);
+ }
+
+ /**
+ * Creates a literal with the specified value and datatype.
+ */
+ public DecimalLiteralImpl(BigDecimal value, URI datatype) {
+ // TODO: maybe DecimalLiteralImpl should not extend LiteralImpl?
+ super(value.toPlainString(), datatype);
+ this.value = value;
+ }
+
+ @Override
+ public byte byteValue()
+ {
+ return value.byteValue();
+ }
+
+ @Override
+ public short shortValue()
+ {
+ return value.shortValue();
+ }
+
+ @Override
+ public int intValue()
+ {
+ return value.intValue();
+ }
+
+ @Override
+ public long longValue()
+ {
+ return value.longValue();
+ }
+
+ @Override
+ public float floatValue()
+ {
+ return value.floatValue();
+ }
+
+ @Override
+ public double doubleValue()
+ {
+ return value.doubleValue();
+ }
+
+ @Override
+ public BigInteger integerValue()
+ {
+ return value.toBigInteger();
+ }
+
+ @Override
+ public BigDecimal decimalValue()
+ {
+ return value;
+ }
+}
View
356 httpdsail/src/org/openrdf/model/impl/GraphImpl.java
@@ -1,178 +1,178 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.model.impl;
-
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.AbstractCollection;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-import info.aduna.collections.iterators.FilterIterator;
-
-import org.openrdf.OpenRDFUtil;
-import org.openrdf.model.Graph;
-import org.openrdf.model.Resource;
-import org.openrdf.model.Statement;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-import org.openrdf.model.ValueFactory;
-
-/**
- * @author Arjohn Kampman
- */
-public class GraphImpl extends AbstractCollection<Statement> implements Graph {
-
- /**
- *
- */
- private static final long serialVersionUID = -5307095904382050478L;
-
- protected LinkedList<Statement> statements;
-
- transient protected ValueFactory valueFactory;
-
- public GraphImpl(ValueFactory valueFactory) {
- super();
- statements = new LinkedList<Statement>();
- setValueFactory(valueFactory);
- }
-
- public GraphImpl() {
- this(new ValueFactoryImpl());
- }
-
- public GraphImpl(ValueFactory valueFactory, Collection<? extends Statement> statements) {
- this(valueFactory);
- addAll(statements);
- }
-
- public GraphImpl(Collection<? extends Statement> statements) {
- this(new ValueFactoryImpl(), statements);
- }
-
- public ValueFactory getValueFactory() {
- return valueFactory;
- }
-
- public void setValueFactory(ValueFactory valueFactory) {
- this.valueFactory = valueFactory;
- }
-
- @Override
- public Iterator<Statement> iterator()
- {
- return statements.iterator();
- }
-
- @Override
- public int size()
- {
- return statements.size();
- }
-
- @Override
- public boolean add(Statement st)
- {
- return statements.add(st);
- }
-
- public boolean add(Resource subj, URI pred, Value obj, Resource... contexts) {
- OpenRDFUtil.verifyContextNotNull(contexts);
-
- boolean graphChanged = false;
-
- if (contexts.length == 0) {
- graphChanged = add(valueFactory.createStatement(subj, pred, obj));
- }
- else {
- for (Resource context : contexts) {
- graphChanged |= add(valueFactory.createStatement(subj, pred, obj, context));
- }
- }
-
- return graphChanged;
- }
-
- public Iterator<Statement> match(Resource subj, URI pred, Value obj, Resource... contexts) {
- OpenRDFUtil.verifyContextNotNull(contexts);
- return new PatternIterator(iterator(), subj, pred, obj, contexts);
- }
-
- private void writeObject(ObjectOutputStream out)
- throws IOException
- {
- out.defaultWriteObject();
- }
-
- private void readObject(ObjectInputStream in)
- throws IOException, ClassNotFoundException
- {
- in.defaultReadObject();
- setValueFactory(new ValueFactoryImpl());
- }
-
- /*-----------------------------*
- * Inner class PatternIterator *
- *-----------------------------*/
-
- private static class PatternIterator extends FilterIterator<Statement> {
-
- private Resource subj;
-
- private URI pred;
-
- private Value obj;
-
- private Resource[] contexts;
-
- public PatternIterator(Iterator<? extends Statement> iter, Resource subj, URI pred, Value obj,
- Resource... contexts)
- {
- super(iter);
- this.subj = subj;
- this.pred = pred;
- this.obj = obj;
- this.contexts = contexts;
- }
-
- @Override
- protected boolean accept(Statement st)
- {
- if (subj != null && !subj.equals(st.getSubject())) {
- return false;
- }
- if (pred != null && !pred.equals(st.getPredicate())) {
- return false;
- }
- if (obj != null && !obj.equals(st.getObject())) {
- return false;
- }
-
- if (contexts.length == 0) {
- // Any context matches
- return true;
- }
- else {
- // Accept if one of the contexts from the pattern matches
- Resource stContext = st.getContext();
-
- for (Resource context : contexts) {
- if (context == null && stContext == null) {
- return true;
- }
- if (context != null && context.equals(stContext)) {
- return true;
- }
- }
-
- return false;
- }
- }
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.model.impl;
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.AbstractCollection;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.LinkedList;
+
+import info.aduna.collections.iterators.FilterIterator;
+
+import org.openrdf.OpenRDFUtil;
+import org.openrdf.model.Graph;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+import org.openrdf.model.ValueFactory;
+
+/**
+ * @author Arjohn Kampman
+ */
+public class GraphImpl extends AbstractCollection<Statement> implements Graph {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = -5307095904382050478L;
+
+ protected LinkedList<Statement> statements;
+
+ transient protected ValueFactory valueFactory;
+
+ public GraphImpl(ValueFactory valueFactory) {
+ super();
+ statements = new LinkedList<Statement>();
+ setValueFactory(valueFactory);
+ }
+
+ public GraphImpl() {
+ this(new ValueFactoryImpl());
+ }
+
+ public GraphImpl(ValueFactory valueFactory, Collection<? extends Statement> statements) {
+ this(valueFactory);
+ addAll(statements);
+ }
+
+ public GraphImpl(Collection<? extends Statement> statements) {
+ this(new ValueFactoryImpl(), statements);
+ }
+
+ public ValueFactory getValueFactory() {
+ return valueFactory;
+ }
+
+ public void setValueFactory(ValueFactory valueFactory) {
+ this.valueFactory = valueFactory;
+ }
+
+ @Override
+ public Iterator<Statement> iterator()
+ {
+ return statements.iterator();
+ }
+
+ @Override
+ public int size()
+ {
+ return statements.size();
+ }
+
+ @Override
+ public boolean add(Statement st)
+ {
+ return statements.add(st);
+ }
+
+ public boolean add(Resource subj, URI pred, Value obj, Resource... contexts) {
+ OpenRDFUtil.verifyContextNotNull(contexts);
+
+ boolean graphChanged = false;
+
+ if (contexts.length == 0) {
+ graphChanged = add(valueFactory.createStatement(subj, pred, obj));
+ }
+ else {
+ for (Resource context : contexts) {
+ graphChanged |= add(valueFactory.createStatement(subj, pred, obj, context));
+ }
+ }
+
+ return graphChanged;
+ }
+
+ public Iterator<Statement> match(Resource subj, URI pred, Value obj, Resource... contexts) {
+ OpenRDFUtil.verifyContextNotNull(contexts);
+ return new PatternIterator(iterator(), subj, pred, obj, contexts);
+ }
+
+ private void writeObject(ObjectOutputStream out)
+ throws IOException
+ {
+ out.defaultWriteObject();
+ }
+
+ private void readObject(ObjectInputStream in)
+ throws IOException, ClassNotFoundException
+ {
+ in.defaultReadObject();
+ setValueFactory(new ValueFactoryImpl());
+ }
+
+ /*-----------------------------*
+ * Inner class PatternIterator *
+ *-----------------------------*/
+
+ private static class PatternIterator extends FilterIterator<Statement> {
+
+ private Resource subj;
+
+ private URI pred;
+
+ private Value obj;
+
+ private Resource[] contexts;
+
+ public PatternIterator(Iterator<? extends Statement> iter, Resource subj, URI pred, Value obj,
+ Resource... contexts)
+ {
+ super(iter);
+ this.subj = subj;
+ this.pred = pred;
+ this.obj = obj;
+ this.contexts = contexts;
+ }
+
+ @Override
+ protected boolean accept(Statement st)
+ {
+ if (subj != null && !subj.equals(st.getSubject())) {
+ return false;
+ }
+ if (pred != null && !pred.equals(st.getPredicate())) {
+ return false;
+ }
+ if (obj != null && !obj.equals(st.getObject())) {
+ return false;
+ }
+
+ if (contexts.length == 0) {
+ // Any context matches
+ return true;
+ }
+ else {
+ // Accept if one of the contexts from the pattern matches
+ Resource stContext = st.getContext();
+
+ for (Resource context : contexts) {
+ if (context == null && stContext == null) {
+ return true;
+ }
+ if (context != null && context.equals(stContext)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+ }
+ }
+}
View
178 httpdsail/src/org/openrdf/model/impl/IntegerLiteralImpl.java
@@ -1,89 +1,89 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.model.impl;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import org.openrdf.model.URI;
-import org.openrdf.model.vocabulary.XMLSchema;
-
-/**
- * An extension of {@link LiteralImpl} that stores an integer value using a
- * {@link BigInteger} object.
- *
- * @author Arjohn Kampman
- */
-public class IntegerLiteralImpl extends LiteralImpl {
-
- private static final long serialVersionUID = 4199641304079427245L;
-
- private final BigInteger value;
-
- /**
- * Creates an xsd:integer literal with the specified value.
- */
- public IntegerLiteralImpl(BigInteger value) {
- this(value, XMLSchema.INTEGER);
- }
-
- /**
- * Creates a literal with the specified value and datatype.
- */
- public IntegerLiteralImpl(BigInteger value, URI datatype) {
- // TODO: maybe IntegerLiteralImpl should not extend LiteralImpl?
- super(value.toString(), datatype);
- this.value = value;
- }
-
- @Override
- public byte byteValue()
- {
- return value.byteValue();
- }
-
- @Override
- public short shortValue()
- {
- return value.shortValue();
- }
-
- @Override
- public int intValue()
- {
- return value.intValue();
- }
-
- @Override
- public long longValue()
- {
- return value.longValue();
- }
-
- @Override
- public float floatValue()
- {
- return value.floatValue();
- }
-
- @Override
- public double doubleValue()
- {
- return value.doubleValue();
- }
-
- @Override
- public BigInteger integerValue()
- {
- return value;
- }
-
- @Override
- public BigDecimal decimalValue()
- {
- return new BigDecimal(value);
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.model.impl;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.vocabulary.XMLSchema;
+
+/**
+ * An extension of {@link LiteralImpl} that stores an integer value using a
+ * {@link BigInteger} object.
+ *
+ * @author Arjohn Kampman
+ */
+public class IntegerLiteralImpl extends LiteralImpl {
+
+ private static final long serialVersionUID = 4199641304079427245L;
+
+ private final BigInteger value;
+
+ /**
+ * Creates an xsd:integer literal with the specified value.
+ */
+ public IntegerLiteralImpl(BigInteger value) {
+ this(value, XMLSchema.INTEGER);
+ }
+
+ /**
+ * Creates a literal with the specified value and datatype.
+ */
+ public IntegerLiteralImpl(BigInteger value, URI datatype) {
+ // TODO: maybe IntegerLiteralImpl should not extend LiteralImpl?
+ super(value.toString(), datatype);
+ this.value = value;
+ }
+
+ @Override
+ public byte byteValue()
+ {
+ return value.byteValue();
+ }
+
+ @Override
+ public short shortValue()
+ {
+ return value.shortValue();
+ }
+
+ @Override
+ public int intValue()
+ {
+ return value.intValue();
+ }
+
+ @Override
+ public long longValue()
+ {
+ return value.longValue();
+ }
+
+ @Override
+ public float floatValue()
+ {
+ return value.floatValue();
+ }
+
+ @Override
+ public double doubleValue()
+ {
+ return value.doubleValue();
+ }
+
+ @Override
+ public BigInteger integerValue()
+ {
+ return value;
+ }
+
+ @Override
+ public BigDecimal decimalValue()
+ {
+ return new BigDecimal(value);
+ }
+}
View
216 httpdsail/src/org/openrdf/model/impl/NumericLiteralImpl.java
@@ -1,108 +1,108 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.model.impl;
-
-import org.openrdf.model.URI;
-import org.openrdf.model.vocabulary.XMLSchema;
-
-/**
- * An extension of {@link LiteralImpl} that stores a numeric value to avoid
- * parsing.
- *
- * @author David Huynh
- */
-public class NumericLiteralImpl extends LiteralImpl {
-
- private static final long serialVersionUID = 3004497457768807919L;
-
- private final Number number;
-
- /**
- * Creates a literal with the specified value and datatype.
- */
- public NumericLiteralImpl(Number number, URI datatype) {
- super(number.toString(), datatype);
- this.number = number;
- }
-
- /**
- * Creates an xsd:byte typed litral with the specified value.
- */
- public NumericLiteralImpl(byte number) {
- this(number, XMLSchema.BYTE);
- }
-
- /**
- * Creates an xsd:short typed litral with the specified value.
- */
- public NumericLiteralImpl(short number) {
- this(number, XMLSchema.SHORT);
- }
-
- /**
- * Creates an xsd:int typed litral with the specified value.
- */
- public NumericLiteralImpl(int number) {
- this(number, XMLSchema.INT);
- }
-
- /**
- * Creates an xsd:long typed litral with the specified value.
- */
- public NumericLiteralImpl(long n) {
- this(n, XMLSchema.LONG);
- }
-
- /**
- * Creates an xsd:float typed litral with the specified value.
- */
- public NumericLiteralImpl(float n) {
- this(n, XMLSchema.FLOAT);
- }
-
- /**
- * Creates an xsd:double typed litral with the specified value.
- */
- public NumericLiteralImpl(double n) {
- this(n, XMLSchema.DOUBLE);
- }
-
- @Override
- public byte byteValue()
- {
- return number.byteValue();
- }
-
- @Override
- public short shortValue()
- {
- return number.shortValue();
- }
-
- @Override
- public int intValue()
- {
- return number.intValue();
- }
-
- @Override
- public long longValue()
- {
- return number.longValue();
- }
-
- @Override
- public float floatValue()
- {
- return number.floatValue();
- }
-
- @Override
- public double doubleValue()
- {
- return number.doubleValue();
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.model.impl;
+
+import org.openrdf.model.URI;
+import org.openrdf.model.vocabulary.XMLSchema;
+
+/**
+ * An extension of {@link LiteralImpl} that stores a numeric value to avoid
+ * parsing.
+ *
+ * @author David Huynh
+ */
+public class NumericLiteralImpl extends LiteralImpl {
+
+ private static final long serialVersionUID = 3004497457768807919L;
+
+ private final Number number;
+
+ /**
+ * Creates a literal with the specified value and datatype.
+ */
+ public NumericLiteralImpl(Number number, URI datatype) {
+ super(number.toString(), datatype);
+ this.number = number;
+ }
+
+ /**
+ * Creates an xsd:byte typed litral with the specified value.
+ */
+ public NumericLiteralImpl(byte number) {
+ this(number, XMLSchema.BYTE);
+ }
+
+ /**
+ * Creates an xsd:short typed litral with the specified value.
+ */
+ public NumericLiteralImpl(short number) {
+ this(number, XMLSchema.SHORT);
+ }
+
+ /**
+ * Creates an xsd:int typed litral with the specified value.
+ */
+ public NumericLiteralImpl(int number) {
+ this(number, XMLSchema.INT);
+ }
+
+ /**
+ * Creates an xsd:long typed litral with the specified value.
+ */
+ public NumericLiteralImpl(long n) {
+ this(n, XMLSchema.LONG);
+ }
+
+ /**
+ * Creates an xsd:float typed litral with the specified value.
+ */
+ public NumericLiteralImpl(float n) {
+ this(n, XMLSchema.FLOAT);
+ }
+
+ /**
+ * Creates an xsd:double typed litral with the specified value.
+ */
+ public NumericLiteralImpl(double n) {
+ this(n, XMLSchema.DOUBLE);
+ }
+
+ @Override
+ public byte byteValue()
+ {
+ return number.byteValue();
+ }
+
+ @Override
+ public short shortValue()
+ {
+ return number.shortValue();
+ }
+
+ @Override
+ public int intValue()
+ {
+ return number.intValue();
+ }
+
+ @Override
+ public long longValue()
+ {
+ return number.longValue();
+ }
+
+ @Override
+ public float floatValue()
+ {
+ return number.floatValue();
+ }
+
+ @Override
+ public double doubleValue()
+ {
+ return number.doubleValue();
+ }
+}
View
210 httpdsail/src/org/openrdf/query/impl/DatasetImpl.java
@@ -1,105 +1,105 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.query.impl;
-
-import java.util.Collections;
-import java.util.LinkedHashSet;
-import java.util.Set;
-
-import org.openrdf.model.URI;
-import org.openrdf.query.Dataset;
-
-/**
- * @author Arjohn Kampman
- */
-public class DatasetImpl implements Dataset {
-
- protected Set<URI> defaultGraphs = new LinkedHashSet<URI>();
-
- protected Set<URI> namedGraphs = new LinkedHashSet<URI>();
-
- public DatasetImpl() {
- }
-
- public Set<URI> getDefaultGraphs() {
- return Collections.unmodifiableSet(defaultGraphs);
- }
-
- /**
- * Adds a graph URI to the set of default graph URIs.
- */
- public void addDefaultGraph(URI graphURI) {
- defaultGraphs.add(graphURI);
- }
-
- /**
- * Removes a graph URI from the set of default graph URIs.
- *
- * @return <tt>true</tt> if the URI was removed from the set,
- * <tt>false</tt> if the set did not contain the URI.
- */
- public boolean removeDefaultGraph(URI graphURI) {
- return defaultGraphs.remove(graphURI);
- }
-
- /**
- * Gets the (unmodifiable) set of named graph URIs.
- */
- public Set<URI> getNamedGraphs() {
- return Collections.unmodifiableSet(namedGraphs);
- }
-
- /**
- * Adds a graph URI to the set of named graph URIs.
- */
- public void addNamedGraph(URI graphURI) {
- namedGraphs.add(graphURI);
- }
-
- /**
- * Removes a graph URI from the set of named graph URIs.
- *
- * @return <tt>true</tt> if the URI was removed from the set,
- * <tt>false</tt> if the set did not contain the URI.
- */
- public boolean removeNamedGraph(URI graphURI) {
- return namedGraphs.remove(graphURI);
- }
-
- /**
- * Removes all graph URIs (both default and named) from this dataset.
- */
- public void clear() {
- defaultGraphs.clear();
- namedGraphs.clear();
- }
-
- @Override
- public String toString() {
- if (defaultGraphs.isEmpty() && namedGraphs.isEmpty())
- return "## empty dataset ##";
- StringBuilder sb = new StringBuilder();
- for (URI uri : defaultGraphs) {
- sb.append("FROM ");
- appendURI(sb, uri);
- }
- for (URI uri : namedGraphs) {
- sb.append("FROM NAMED ");
- appendURI(sb, uri);
- }
- return sb.toString();
- }
-
- private void appendURI(StringBuilder sb, URI uri) {
- String str = uri.toString();
- if (str.length() > 50) {
- sb.append("<").append(str, 0, 19).append("..");
- sb.append(str, str.length() - 29, str.length()).append(">\n");
- } else {
- sb.append("<").append(uri).append(">\n");
- }
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.query.impl;
+
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.Set;
+
+import org.openrdf.model.URI;
+import org.openrdf.query.Dataset;
+
+/**
+ * @author Arjohn Kampman
+ */
+public class DatasetImpl implements Dataset {
+
+ protected Set<URI> defaultGraphs = new LinkedHashSet<URI>();
+
+ protected Set<URI> namedGraphs = new LinkedHashSet<URI>();
+
+ public DatasetImpl() {
+ }
+
+ public Set<URI> getDefaultGraphs() {
+ return Collections.unmodifiableSet(defaultGraphs);
+ }
+
+ /**
+ * Adds a graph URI to the set of default graph URIs.
+ */
+ public void addDefaultGraph(URI graphURI) {
+ defaultGraphs.add(graphURI);
+ }
+
+ /**
+ * Removes a graph URI from the set of default graph URIs.
+ *
+ * @return <tt>true</tt> if the URI was removed from the set,
+ * <tt>false</tt> if the set did not contain the URI.
+ */
+ public boolean removeDefaultGraph(URI graphURI) {
+ return defaultGraphs.remove(graphURI);
+ }
+
+ /**
+ * Gets the (unmodifiable) set of named graph URIs.
+ */
+ public Set<URI> getNamedGraphs() {
+ return Collections.unmodifiableSet(namedGraphs);
+ }
+
+ /**
+ * Adds a graph URI to the set of named graph URIs.
+ */
+ public void addNamedGraph(URI graphURI) {
+ namedGraphs.add(graphURI);
+ }
+
+ /**
+ * Removes a graph URI from the set of named graph URIs.
+ *
+ * @return <tt>true</tt> if the URI was removed from the set,
+ * <tt>false</tt> if the set did not contain the URI.
+ */
+ public boolean removeNamedGraph(URI graphURI) {
+ return namedGraphs.remove(graphURI);
+ }
+
+ /**
+ * Removes all graph URIs (both default and named) from this dataset.
+ */
+ public void clear() {
+ defaultGraphs.clear();
+ namedGraphs.clear();
+ }
+
+ @Override
+ public String toString() {
+ if (defaultGraphs.isEmpty() && namedGraphs.isEmpty())
+ return "## empty dataset ##";
+ StringBuilder sb = new StringBuilder();
+ for (URI uri : defaultGraphs) {
+ sb.append("FROM ");
+ appendURI(sb, uri);
+ }
+ for (URI uri : namedGraphs) {
+ sb.append("FROM NAMED ");
+ appendURI(sb, uri);
+ }
+ return sb.toString();
+ }
+
+ private void appendURI(StringBuilder sb, URI uri) {
+ String str = uri.toString();
+ if (str.length() > 50) {
+ sb.append("<").append(str, 0, 19).append("..");
+ sb.append(str, str.length() - 29, str.length()).append(">\n");
+ } else {
+ sb.append("<").append(uri).append(">\n");
+ }
+ }
+}
View
210 httpdsail/src/org/openrdf/query/impl/EmptyBindingSet.java
@@ -1,105 +1,105 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.query.impl;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import org.openrdf.model.Value;
-import org.openrdf.query.Binding;
-import org.openrdf.query.BindingSet;
-
-/**
- * An immutable empty BindingSet.
- *
- * @author Arjohn Kampman
- */
-public class EmptyBindingSet implements BindingSet {
-
- /*-----------*
- * Constants *
- *-----------*/
-
- private static final EmptyBindingSet singleton = new EmptyBindingSet();
-
- public static BindingSet getInstance() {
- return singleton;
- }
-
- /*-----------*
- * Variables *
- *-----------*/
-
- private EmptyBindingIterator iter = new EmptyBindingIterator();
-
- /*---------*
- * Methods *
- *---------*/
-
- public Iterator<Binding> iterator() {
- return iter;
- }
-
- public Set<String> getBindingNames() {
- return Collections.emptySet();
- }
-
- public Binding getBinding(String bindingName) {
- return null;
- }
-
- public boolean hasBinding(String bindingName) {
- return false;
- }
-
- public Value getValue(String bindingName) {
- return null;
- }
-
- public int size() {
- return 0;
- }
-
- @Override
- public boolean equals(Object o) {
- if (o instanceof BindingSet) {
- return ((BindingSet)o).size() == 0;
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- return 0;
- }
-
- @Override
- public String toString() {
- return "[]";
- }
-
- /*----------------------------------*
- * Inner class EmptyBindingIterator *
- *----------------------------------*/
-
- private static class EmptyBindingIterator implements Iterator<Binding> {
-
- public boolean hasNext() {
- return false;
- }
-
- public Binding next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new IllegalStateException();
- }
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.query.impl;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import org.openrdf.model.Value;
+import org.openrdf.query.Binding;
+import org.openrdf.query.BindingSet;
+
+/**
+ * An immutable empty BindingSet.
+ *
+ * @author Arjohn Kampman
+ */
+public class EmptyBindingSet implements BindingSet {
+
+ /*-----------*
+ * Constants *
+ *-----------*/
+
+ private static final EmptyBindingSet singleton = new EmptyBindingSet();
+
+ public static BindingSet getInstance() {
+ return singleton;
+ }
+
+ /*-----------*
+ * Variables *
+ *-----------*/
+
+ private EmptyBindingIterator iter = new EmptyBindingIterator();
+
+ /*---------*
+ * Methods *
+ *---------*/
+
+ public Iterator<Binding> iterator() {
+ return iter;
+ }
+
+ public Set<String> getBindingNames() {
+ return Collections.emptySet();
+ }
+
+ public Binding getBinding(String bindingName) {
+ return null;
+ }
+
+ public boolean hasBinding(String bindingName) {
+ return false;
+ }
+
+ public Value getValue(String bindingName) {
+ return null;
+ }
+
+ public int size() {
+ return 0;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o instanceof BindingSet) {
+ return ((BindingSet)o).size() == 0;
+ }
+
+ return false;
+ }
+
+ @Override
+ public int hashCode() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "[]";
+ }
+
+ /*----------------------------------*
+ * Inner class EmptyBindingIterator *
+ *----------------------------------*/
+
+ private static class EmptyBindingIterator implements Iterator<Binding> {
+
+ public boolean hasNext() {
+ return false;
+ }
+
+ public Binding next() {
+ throw new NoSuchElementException();
+ }
+
+ public void remove() {
+ throw new IllegalStateException();
+ }
+ }
+}
View
124 httpdsail/src/org/openrdf/query/impl/GraphQueryResultImpl.java
@@ -1,62 +1,62 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2006-2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.query.impl;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-
-import info.aduna.iteration.CloseableIteration;
-import info.aduna.iteration.CloseableIteratorIteration;
-import info.aduna.iteration.IterationWrapper;
-
-import org.openrdf.model.Statement;
-import org.openrdf.query.GraphQueryResult;
-import org.openrdf.query.QueryEvaluationException;
-
-/**
- * An utility implementation of the {@link GraphQueryResult} interface.
- *
- * @author Arjohn Kampman
- * @author jeen
- */
-public class GraphQueryResultImpl extends IterationWrapper<Statement, QueryEvaluationException> implements
- GraphQueryResult
-{
-
- /*-----------*
- * Variables *
- *-----------*/
-
- private Map<String, String> namespaces;
-
- /*--------------*
- * Constructors *
- *--------------*/
-
- public GraphQueryResultImpl(Map<String, String> namespaces, Iterable<? extends Statement> statements) {
- this(namespaces, statements.iterator());
- }
-
- public GraphQueryResultImpl(Map<String, String> namespaces, Iterator<? extends Statement> statementIter) {
- this(namespaces, new CloseableIteratorIteration<Statement, QueryEvaluationException>(statementIter));
- }
-
- public GraphQueryResultImpl(Map<String, String> namespaces,
- CloseableIteration<? extends Statement, ? extends QueryEvaluationException> statementIter)
- {
- super(statementIter);
- this.namespaces = Collections.unmodifiableMap(namespaces);
- }
-
- /*---------*
- * Methods *
- *---------*/
-
- public Map<String, String> getNamespaces() {
- return namespaces;
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2006-2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.query.impl;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+import info.aduna.iteration.CloseableIteration;
+import info.aduna.iteration.CloseableIteratorIteration;
+import info.aduna.iteration.IterationWrapper;
+
+import org.openrdf.model.Statement;
+import org.openrdf.query.GraphQueryResult;
+import org.openrdf.query.QueryEvaluationException;
+
+/**
+ * An utility implementation of the {@link GraphQueryResult} interface.
+ *
+ * @author Arjohn Kampman
+ * @author jeen
+ */
+public class GraphQueryResultImpl extends IterationWrapper<Statement, QueryEvaluationException> implements
+ GraphQueryResult
+{
+
+ /*-----------*
+ * Variables *
+ *-----------*/
+
+ private Map<String, String> namespaces;
+
+ /*--------------*
+ * Constructors *
+ *--------------*/
+
+ public GraphQueryResultImpl(Map<String, String> namespaces, Iterable<? extends Statement> statements) {
+ this(namespaces, statements.iterator());
+ }
+
+ public GraphQueryResultImpl(Map<String, String> namespaces, Iterator<? extends Statement> statementIter) {
+ this(namespaces, new CloseableIteratorIteration<Statement, QueryEvaluationException>(statementIter));
+ }
+
+ public GraphQueryResultImpl(Map<String, String> namespaces,
+ CloseableIteration<? extends Statement, ? extends QueryEvaluationException> statementIter)
+ {
+ super(statementIter);
+ this.namespaces = Collections.unmodifiableMap(namespaces);
+ }
+
+ /*---------*
+ * Methods *
+ *---------*/
+
+ public Map<String, String> getNamespaces() {
+ return namespaces;
+ }
+}
View
520 httpdsail/src/org/openrdf/query/impl/MutableTupleQueryResult.java
@@ -1,260 +1,260 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.query.impl;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.NoSuchElementException;
-import java.util.Set;
-
-import info.aduna.iteration.Iteration;
-import info.aduna.iteration.Iterations;
-
-import org.openrdf.query.BindingSet;
-import org.openrdf.query.QueryEvaluationException;
-import org.openrdf.query.TupleQueryResult;
-
-/**
- * An implementation of the {@link TupleQueryResult} interface that stores the
- * complete query result in memory. The query results in a
- * MutableTupleQueryResult can be iterated over multiple times and can also be
- * iterated over in reverse order.
- *
- * @author Arjohn Kampman
- */
-public class MutableTupleQueryResult implements TupleQueryResult, Cloneable {
-
- /*-----------*
- * Variables *
- *-----------*/
-
- private Set<String> bindingNames = new LinkedHashSet<String>();
-
- private List<BindingSet> bindingSets = new LinkedList<BindingSet>();
-
- /**
- * The index of the next element that will be returned by a call to
- * {@link #next()}.
- */
- private int currentIndex = 0;
-
- /**
- * The index of the last element that was returned by a call to
- * {@link #next()} or {@link #previous()}. Equal to -1 if there is no such
- * element.
- */
- private int lastReturned = -1;
-
- /*--------------*
- * Constructors *
- *--------------*/
-
- public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames,
- BindingSet... bindingSets)
- {
- this(bindingNames, Arrays.asList(bindingSets));
- }
-
- /**
- * Creates a query result table with the supplied binding names.
- * <em>The supplied list of binding names is assumed to be constant</em>;
- * care should be taken that the contents of this list doesn't change after
- * supplying it to this solution.
- *
- * @param bindingNames
- * The binding names, in order of projection.
- */
- public MutableTupleQueryResult(Collection<String> bindingNames,
- Collection<? extends BindingSet> bindingSets)
- {
- this.bindingNames.addAll(bindingNames);
- this.bindingSets.addAll(bindingSets);
- }
-
- public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames,
- Iteration<? extends BindingSet, E> bindingSetIter)
- throws E
- {
- this.bindingNames.addAll(bindingNames);
- Iterations.addAll(bindingSetIter, this.bindingSets);
- }
-
- public MutableTupleQueryResult(TupleQueryResult tqr)
- throws QueryEvaluationException
- {
- this(tqr.getBindingNames(), tqr);
- }
-
- /*---------*
- * Methods *
- *---------*/
-
- public List<String> getBindingNames() {
- return new ArrayList<String>(bindingNames);
- }
-
- public int size() {
- return bindingSets.size();
- }
-
- public BindingSet get(int index) {
- return bindingSets.get(index);
- }
-
- public int getIndex() {
- return currentIndex;
- }
-
- public void setIndex(int index) {
- if (index < 0 || index > bindingSets.size() + 1) {
- throw new IllegalArgumentException("Index out of range: " + index);
- }
-
- this.currentIndex = index;
- }
-
- public boolean hasNext() {
- return currentIndex < bindingSets.size();
- }
-
- public BindingSet next() {
- if (hasNext()) {
- BindingSet result = get(currentIndex);
- lastReturned = currentIndex;
- currentIndex++;
- return result;
- }
-
- throw new NoSuchElementException();
- }
-
- public boolean hasPrevious() {
- return currentIndex > 0;
- }
-
- public BindingSet previous() {
- if (hasPrevious()) {
- BindingSet result = bindingSets.get(currentIndex - 1);
- currentIndex--;
- lastReturned = currentIndex;
- return result;
- }
-
- throw new NoSuchElementException();
- }
-
- /**
- * Moves the cursor to the start of the query result, just before the first
- * binding set. After calling this method, the result can be iterated over
- * from scratch.
- */
- public void beforeFirst() {
- currentIndex = 0;
- }
-
- /**
- * Moves the cursor to the end of the query result, just after the last
- * binding set.
- */
- public void afterLast() {
- currentIndex = bindingSets.size() + 1;
- }
-
- /**
- * Inserts the specified binding set into the list. The binding set is
- * inserted immediately before the next element that would be returned by
- * {@link #next()}, if any, and after the next element that would be
- * returned by {@link #previous}, if any. (If the table contains no binding
- * sets, the new element becomes the sole element on the table.) The new
- * element is inserted before the implicit cursor: a subsequent call to
- * <tt>next()</tt> would be unaffected, and a subsequent call to
- * <tt>previous()</tt> would return the new binding set.
- *
- * @param bindingSet
- * The binding set to insert.
- */
- public void insert(BindingSet bindingSet) {
- insert(currentIndex, bindingSet);
- }
-
- public void insert(int index, BindingSet bindingSet) {
- bindingSets.add(index, bindingSet);
-
- if (currentIndex > index) {
- currentIndex++;
- }
-
- lastReturned = -1;
- }
-
- public void append(BindingSet bindingSet) {
- bindingSets.add(bindingSet);
- lastReturned = -1;
- }
-
- public void set(BindingSet bindingSet) {
- if (lastReturned == -1) {
- throw new IllegalStateException();
- }
-
- set(lastReturned, bindingSet);
- }
-
- public BindingSet set(int index, BindingSet bindingSet) {
- return bindingSets.set(index, bindingSet);
- }
-
- public void remove() {
- if (lastReturned == -1) {
- throw new IllegalStateException();
- }
-
- remove(lastReturned);
-
- if (currentIndex > lastReturned) {
- currentIndex--;
- }
-
- lastReturned = -1;
- }
-
- public BindingSet remove(int index) {
- BindingSet result = bindingSets.remove(index);
-
- if (currentIndex > index) {
- currentIndex--;
- }
-
- lastReturned = -1;
-
- return result;
- }
-
- public void clear() {
- bindingNames.clear();
- bindingSets.clear();
- currentIndex = 0;
- lastReturned = -1;
- }
-
- public void close() {
- // no-opp
- }
-
- @Override
- public MutableTupleQueryResult clone()
- throws CloneNotSupportedException
- {
- MutableTupleQueryResult clone = (MutableTupleQueryResult)super.clone();
- clone.bindingNames = new LinkedHashSet<String>(bindingNames);
- clone.bindingSets = new LinkedList<BindingSet>(bindingSets);
- return clone;
- }
-}
+/*
+ * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
+ *
+ * Licensed under the Aduna BSD-style license.
+ */
+package org.openrdf.query.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.LinkedHashSet;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.Set;
+
+import info.aduna.iteration.Iteration;
+import info.aduna.iteration.Iterations;
+
+import org.openrdf.query.BindingSet;
+import org.openrdf.query.QueryEvaluationException;
+import org.openrdf.query.TupleQueryResult;
+
+/**
+ * An implementation of the {@link TupleQueryResult} interface that stores the
+ * complete query result in memory. The query results in a
+ * MutableTupleQueryResult can be iterated over multiple times and can also be
+ * iterated over in reverse order.
+ *
+ * @author Arjohn Kampman
+ */
+public class MutableTupleQueryResult implements TupleQueryResult, Cloneable {
+
+ /*-----------*
+ * Variables *
+ *-----------*/
+
+ private Set<String> bindingNames = new LinkedHashSet<String>();
+
+ private List<BindingSet> bindingSets = new LinkedList<BindingSet>();
+
+ /**
+ * The index of the next element that will be returned by a call to
+ * {@link #next()}.
+ */
+ private int currentIndex = 0;
+
+ /**
+ * The index of the last element that was returned by a call to
+ * {@link #next()} or {@link #previous()}. Equal to -1 if there is no such
+ * element.
+ */
+ private int lastReturned = -1;
+
+ /*--------------*
+ * Constructors *
+ *--------------*/
+
+ public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames,
+ BindingSet... bindingSets)
+ {
+ this(bindingNames, Arrays.asList(bindingSets));
+ }
+
+ /**
+ * Creates a query result table with the supplied binding names.
+ * <em>The supplied list of binding names is assumed to be constant</em>;
+ * care should be taken that the contents of this list doesn't change after
+ * supplying it to this solution.
+ *
+ * @param bindingNames
+ * The binding names, in order of projection.
+ */
+ public MutableTupleQueryResult(Collection<String> bindingNames,
+ Collection<? extends BindingSet> bindingSets)
+ {
+ this.bindingNames.addAll(bindingNames);
+ this.bindingSets.addAll(bindingSets);
+ }
+
+ public <E extends Exception> MutableTupleQueryResult(Collection<String> bindingNames,
+ Iteration<? extends BindingSet, E> bindingSetIter)
+ throws E
+ {
+ this.bindingNames.addAll(bindingNames);
+ Iterations.addAll(bindingSetIter, this.bindingSets);
+ }
+
+ public MutableTupleQueryResult(TupleQueryResult tqr)
+ throws QueryEvaluationException
+ {
+ this(tqr.getBindingNames(), tqr);
+ }
+
+ /*---------*
+ * Methods *
+ *---------*/
+
+ public List<String> getBindingNames() {
+ return new ArrayList<String>(bindingNames);
+ }
+
+ public int size() {
+ return bindingSets.size();
+ }
+
+ public BindingSet get(int index) {
+ return bindingSets.get(index);
+ }
+
+ public int getIndex() {
+ return currentIndex;
+ }
+
+ public void setIndex(int index) {
+ if (index < 0 || index > bindingSets.size() + 1) {
+ throw new IllegalArgumentException("Index out of range: " + index);
+ }
+
+ this.currentIndex = index;
+ }
+
+ public boolean hasNext() {
+ return currentIndex < bindingSets.size();
+ }
+
+ public BindingSet next() {
+ if (hasNext()) {
+ BindingSet result = get(currentIndex);
+ lastReturned = currentIndex;
+ currentIndex++;
+ return result;
+ }
+
+ throw new NoSuchElementException();
+ }
+
+ public boolean hasPrevious() {
+ return currentIndex > 0;
+ }
+
+ public BindingSet previous() {
+ if (hasPrevious()) {
+ BindingSet result = bindingSets.get(currentIndex - 1);
+ currentIndex--;
+ lastReturned = currentIndex;
+ return result;
+ }
+
+ throw new NoSuchElementException();
+ }
+
+ /**
+ * Moves the cursor to the start of the query result, just before the first
+ * binding set. After calling this method, the result can be iterated over
+ * from scratch.
+ */
+ public void beforeFirst() {
+ currentIndex = 0;
+ }
+
+ /**
+ * Moves the cursor to the end of the query result, just after the last
+ * binding set.
+ */
+ public void afterLast() {
+ currentIndex = bindingSets.size() + 1;
+ }
+
+ /**
+ * Inserts the specified binding set into the list. The binding set is
+ * inserted immediately before the next element that would be returned by
+ * {@link #next()}, if any, and after the next element that would be
+ * returned by {@link #previous}, if any. (If the table contains no binding
+ * sets, the new element becomes the sole element on the table.) The new
+ * element is inserted before the implicit cursor: a subsequent call to
+ * <tt>next()</tt> would be unaffected, and a subsequent call to
+ * <tt>previous()</tt> would return the new binding set.
+ *
+ * @param bindingSet
+ * The binding set to insert.
+ */
+ public void insert(BindingSet bindingSet) {
+ insert(currentIndex, bindingSet);
+ }
+
+ public void insert(int index, BindingSet bindingSet) {
+ bindingSets.add(index, bindingSet);
+
+ if (currentIndex > index) {
+ currentIndex++;
+ }
+
+ lastReturned = -1;
+ }
+
+ public void append(BindingSet bindingSet) {
+ bindingSets.add(bindingSet);
+ lastReturned = -1;
+ }
+
+ public void set(BindingSet bindingSet) {
+ if (lastReturned == -1) {
+ throw new IllegalStateException();
+ }
+
+ set(lastReturned, bindingSet);
+ }
+
+ public BindingSet set(int index, BindingSet bindingSet) {
+ return bindingSets.set(index, bindingSet);
+ }
+
+ public void remove() {
+ if (lastReturned == -1) {
+ throw new IllegalStateException();
+ }
+
+ remove(lastReturned);
+
+ if (currentIndex > lastReturned) {
+ currentIndex--;
+ }
+
+ lastReturned = -1;
+ }
+
+ public BindingSet remove(int index) {
+ BindingSet result = bindingSets.remove(index);
+
+ if (currentIndex > index) {
+ currentIndex--;
+ }
+
+ lastReturned = -1;
+
+ return result;
+ }
+
+ public void clear() {
+ bindingNames.clear();
+ bindingSets.clear();
+ currentIndex = 0;
+ lastReturned = -1;
+ }
+
+ public void close() {
+ // no-opp
+ }
+
+ @Override
+ public MutableTupleQueryResult clone()
+ throws CloneNotSupportedException
+ {
+ MutableTupleQueryResult clone = (MutableTupleQueryResult)super.clone();
+ clone.bindingNames = new LinkedHashSet<String>(bindingNames);
+ clone.bindingSets = new LinkedList<BindingSet>(bindingSets);
+ return clone;
+ }
+}
View
572 httpdsail/src/org/openrdf/repository/sail/AllegroRepository.java
@@ -1,286 +1,286 @@
-/*
- * Copyright Aduna (http://www.aduna-software.com/) (c) 1997-2006.
- *
- * Licensed under the Aduna BSD-style license.
- */
-package org.openrdf.repository.sail;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.openrdf.model.ValueFactory;
-import org.openrdf.repository.Repository;
-import org.openrdf.repository.RepositoryConnection;
-import org.openrdf.sail.Sail;
-
-import franz.exceptions.ServerException;
-import franz.exceptions.SoftException;
-import franz.exceptions.UnimplementedMethodException;
-
-/**
- * An implementation of the {@link Repository} interface that operates on a
- * (stack of) {@link Sail Sail} object(s). The behaviour of the repository is
- * determined by the Sail stack that it operates on; for example, the repository
- * will only support RDF Schema or OWL semantics if the Sail stack includes an
- * inferencer for this.
- * <p>
- * Creating a repository object of this type is very easy. For example, the
- * following code creates and initializes a main-memory store with RDF Schema
- * semantics:
- *
- * <pre>
- * Repository repository = new RepositoryImpl(new ForwardChainingRDFSInferencer(new MemoryStore()));
- * repository.initialize();
- * </pre>
- *
- * Or, alternatively:
- *
- * <pre>
- * Sail sailStack = new MemoryStore();
- * sailStack = new ForwardChainingRDFSInferencer(sailStack);
- *
- * Repository repository = new Repository(sailStack);
- * repository.initialize();
- * </pre>
- *
- */
-public class AllegroRepository implements Repository {
-
- private String accessVerb = null;
- private miniclient.Catalog miniCatalog = null;
- private miniclient.Repository miniRepository;
- private String repositoryName = null;
- private boolean isInitialized = false;
- //private AllegroRepositoryConnection repositoryConnection = null;
- private Map<String, String> inlinedPredicates = new HashMap<String, String>();
- private Map<String, String> inlinedDatatypes = new HashMap<String, String>();
- private Set<String> federatedTripleStores = null;
-
- private AllegroValueFactory valueFactory = null;
-
- public static String RENEW = "RENEW";
- public static String CREATE = "CREATE";
- public static String OPEN = "OPEN";
- public static String ACCESS = "ACCESS";
-
- /**
- * Constructor. Create a new Sail that operates on the triple store that 'miniRepository'
- * connects to.
- */
- protected AllegroRepository(Catalog catalog, String repositoryName, String accessVerb) {
- this.miniCatalog = catalog.getMiniCatalog();
- this.repositoryName = repositoryName;
- this.accessVerb = accessVerb;
- }
-
- protected miniclient.Repository getMiniRepository() {
- this.verify();
- return this.miniRepository;
- }
-
- public String getName () {return this.repositoryName;}
-
- public Map<String, String> getInlinedPredicates () {
- return this.inlinedPredicates;
- }
-
- public Map<String, String> getInlinedDatatypes () {
- return this.inlinedDatatypes;
- }
-
-
-
-
- public File getDataDir() {
- throw new UnimplementedMethodException("getDataDir");
- }
-
- public void setDataDir(File dataDir) {
- throw new UnimplementedMethodException("setDataDir");
- }
-
- private void createTripleStore (String quotedDbName) {
- miniclient.Catalog miniCat = this.miniCatalog;
- if (this.federatedTripleStores != null) {
- List<String> stores = new ArrayList<String>();
- for (String ts : this.federatedTripleStores) {
- stores.add(AllegroSail.quotePlus(ts));
- }
- miniCat.federateTripleStores(quotedDbName, stores);
- }
- else {
- miniCat.createTripleStore(quotedDbName);
- }
-}
- private void attachToMiniRepository() {
- String quotedRepName = AllegroSail.quotePlus(this.repositoryName);
- miniclient.Catalog miniCat = this.miniCatalog;
- if (this.accessVerb == RENEW) {
- if (miniCat.listTripleStores().contains(quotedRepName)) {
- // not nice, since someone else probably has it open:
- miniCat.deleteTripleStore(quotedRepName);
- }
- this.createTripleStore(quotedRepName);
- } else if (this.accessVerb == CREATE) {
- if (miniCat.listTripleStores().contains(quotedRepName)) {
- throw new ServerException(
- "Can't create triple store named '" + this.repositoryName + "' because a store with that name already exists.");
- }
- this.createTripleStore(quotedRepName);
- } else if (this.accessVerb == OPEN) {
- if (!miniCat.listTripleStores().contains(quotedRepName)) {
- throw new ServerException(
- "Can't open a triple store named '" + this.repositoryName + "' because there is none.");
- }
- } else if(this.accessVerb == ACCESS) {
- if (!miniCat.listTripleStores().contains(quotedRepName)) {
- this.createTripleStore(quotedRepName);
- }
- }
- this.miniRepository = miniCat.getRepository(quotedRepName);
- }
-
- /**
- * Create internal repository object that makes 'this' a functioning repository.
- */
- public void initialize() {
- if (this.isInitialized) {
- throw new SoftException("A repository cannot be initialized twice.");
- }
- this.attachToMiniRepository();
-// ## EXPERIMENTATION WITH INITIALIZING AN ENVIRONMENT. DIDN'T LOOK RIGHT - RMM
-//# self.environment = self.mini_repository.createEnvironment()
-//# print "ENV", self.environment
-//# self.mini_repository.deleteEnvironment(self.environment)
-//# print "ENV AfTER", self.mini_repository.listEnvironments()
- this.isInitialized = true;
- }
-
- /**
- * Chainable version of 'init'. What 'initialize' should have been if it were better conceived.
- */
- public AllegroRepository init() {
- this.initialize();
- return this;
- }
-
-
- /**
- * Make this repository a federated store that includes the stores named in
- * 'tripleStoreNames'. This call must precede the call to 'initialize'. It
- * may be called multiple times.
- */
- public AllegroRepository addFederatedTripleStores(List<String> tripleStoreNames) {
- if (this.isInitialized)
- throw new SoftException("Federated triples stores must be added prior to calling 'initialize'.");
- if ((this.accessVerb != AllegroRepository.CREATE) && (this.accessVerb != AllegroRepository.RENEW))
- throw new SoftException("Adding federated triple stores requires a CREATE or RENEW access option.\n" +
- "The current access is set to '" + this.accessVerb + "'.");
- if (this.federatedTripleStores == null)
- this.federatedTripleStores = new HashSet<String>();
- for (String ts : tripleStoreNames)
- this.federatedTripleStores.add(ts);
- return this;
- }
-
- private void verify () {
- if (this.miniCatalog != null && this.miniRepository != null) return;
- else if (this.miniCatalog == null)
- throw new ServerException("Attempt to use the repository after it has been closed.");
- else
- throw new ServerException("Attempt to use the repository before it has been initialized.");
- }
-
- public void shutDown() {
- this.miniCatalog = null;
- this.miniRepository = null;
- }
-
-
- public boolean isWritable() {
- this.verify();
- return this.miniRepository.isWriteable();
- }
-
- public ValueFactory getValueFactory() {
- if (this.valueFactory == null) {
- this.valueFactory = new AllegroValueFactory(this);
- }
- return this.valueFactory;
- }
-
- public RepositoryConnection getConnection() {
- this.verify();
-// if (this.repositoryConnection == null) {
-// this.repositoryConnection = new AllegroRepositoryConnection(this);
-// }
-// return this.repositoryConnection;
- // Sesame JUnits test insists on supporting multiple connections to same repository:
- // Not clear that there is any value in that:
- return new AllegroRepositoryConnection(this);
- }
-
- //------------------------------------------------------------------------
- // Extensions to the Sesame API
- //------------------------------------------------------------------------
-
- /**
- Index the newly-added triples in the store. This should be done after every
- significant-sized load of triples into the store.
- If 'all', re-index all triples in the store. If 'asynchronous', spawn
- the indexing task as a separate thread, and don't wait for it to complete.
- Note. Upon version 4.0, calling this will no longer be necessary.
- */
- public void indexTriples(boolean all) {
- this.miniRepository.indexStatements(all);
- }
-
- /**
- Register a predicate 'uri' (or 'namespace'+'localname'), telling the RDF store to index
- text keywords belonging to strings in object position in the corresponding
- triples/statements. This is needed to make the fti:match operator
- work properly.
- */
- public void registerFreeTextPredicate(String uri) {
- this.miniRepository.registerFreeTextPredicate("<" + uri + ">");
- }
-
-
-// private void translate_inlined_type(String type) {
-// if (type == "int") return "int";
-// else if (type == "datetime") return "date-time";
-// else if (type == "float") return "float";
-// else
-// throw new XXX("Unknown inlined type '%s'\n. Legal types are " +
-// "'int', 'float', and 'datetime'");
-// }
-//
-// def registerInlinedDatatype(self, predicate=None, datatype=None, inlinedType=None):
-// """
-// Register an inlined datatype. If 'predicate', then object arguments to triples
-// with that predicate will use an inlined encoding of type 'inlinedType' in their
-// internal representation.
-// If 'datatype', then typed literal objects with a datatype matching 'datatype' will
-// use an inlined encoding of type 'inlinedType'.
-// """
-// predicate = predicate.getURI() if isinstance(predicate, URI) else predicate
-// datatype = datatype.getURI() if isinstance(datatype, URI) else datatype
-// if predicate:
-// if not inlinedType: