[dna-commits] DNA SVN: r180 - in branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph: impl and 1 other directory.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Mon May 19 16:27:57 EDT 2008


Author: rhauch
Date: 2008-05-19 16:27:57 -0400 (Mon, 19 May 2008)
New Revision: 180

Removed:
   branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/Values.java
Modified:
   branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
   branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
Log:
DNA-67: Create graph API for federation engine
http://jira.jboss.org/jira/browse/DNA-67

Added a create(Object) method on ValueFactory, and added an implementation of the method to the AbstractValueFactory.  Also removed the unused "Values" interface.

Modified: branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java
===================================================================
--- branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java	2008-05-19 20:26:50 UTC (rev 179)
+++ branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/ValueFactory.java	2008-05-19 20:27:57 UTC (rev 180)
@@ -189,4 +189,14 @@
      */
     T create( Reader reader, int approximateLength ) throws ValueFormatException, IOException;
 
+    /**
+     * Create a value from the specified information by determining which other <code>create</code> method applies and
+     * delegating to that method. Note that this method only will call <code>create</code> methods that take a single parameter;
+     * so this excludes {@link #create(InputStream, int)}, {@link #create(Reader, int)} and {@link #create(String, TextEncoder)}.
+     * @param value the value
+     * @return the new value, or null if the supplied parameter is null
+     * @throws ValueFormatException if the value could not be created from the supplied stream
+     */
+    T create( Object value ) throws ValueFormatException;
+
 }

Deleted: branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/Values.java
===================================================================
--- branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/Values.java	2008-05-19 20:26:50 UTC (rev 179)
+++ branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/Values.java	2008-05-19 20:27:57 UTC (rev 180)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.spi.graph;
-
-
-/**
- * 
- * @author Randall Hauch
- */
-public class Values {
-
-}

Modified: branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java
===================================================================
--- branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java	2008-05-19 20:26:50 UTC (rev 179)
+++ branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/graph/impl/AbstractValueFactory.java	2008-05-19 20:27:57 UTC (rev 180)
@@ -21,11 +21,19 @@
  */
 package org.jboss.dna.spi.graph.impl;
 
+import java.math.BigDecimal;
+import java.net.URI;
+import java.util.Calendar;
+import java.util.Date;
 import net.jcip.annotations.Immutable;
 import org.jboss.dna.common.text.TextEncoder;
 import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Path;
 import org.jboss.dna.spi.graph.PropertyType;
+import org.jboss.dna.spi.graph.Reference;
 import org.jboss.dna.spi.graph.ValueFactory;
+import org.jboss.dna.spi.graph.ValueFormatException;
 
 /**
  * Abstract {@link ValueFactory}.
@@ -77,4 +85,25 @@
         return propertyType;
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public T create( Object value ) throws ValueFormatException {
+        if (value == null) return null;
+        if (value instanceof String) return create((String)value);
+        if (value instanceof Integer) return create(((Integer)value).intValue());
+        if (value instanceof Long) return create(((Long)value).longValue());
+        if (value instanceof Double) return create(((Double)value).doubleValue());
+        if (value instanceof Float) return create(((Float)value).floatValue());
+        if (value instanceof Boolean) return create(((Boolean)value).booleanValue());
+        if (value instanceof BigDecimal) return create((BigDecimal)value);
+        if (value instanceof Calendar) return create((Calendar)value);
+        if (value instanceof Date) return create((Date)value);
+        if (value instanceof Name) return create((Name)value);
+        if (value instanceof Path) return create((Path)value);
+        if (value instanceof Reference) return create((Reference)value);
+        if (value instanceof URI) return create((URI)value);
+        return create(value.toString());
+    }
+
 }




More information about the dna-commits mailing list