jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject svn commit: r1432473 - in /jena/trunk/jena-core/src: main/java/com/hp/hpl/jena/enhanced/EnhNode.java main/java/com/hp/hpl/jena/enhanced/UnsupportedPolymorphismException.java test/java/com/hp/hpl/jena/enhanced/test/TestPackage.java
Date Sat, 12 Jan 2013 16:59:53 GMT
Author: andy
Date: Sat Jan 12 16:59:53 2013
New Revision: 1432473

URL: http://svn.apache.org/viewvc?rev=1432473&view=rev
Log:
JENA-372 : Remove dependency on EnhNode by UnsupportedPolymorphismException

Modified:
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/EnhNode.java
    jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/UnsupportedPolymorphismException.java
    jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/enhanced/test/TestPackage.java

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/EnhNode.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/EnhNode.java?rev=1432473&r1=1432472&r2=1432473&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/EnhNode.java (original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/EnhNode.java Sat Jan 12 16:59:53
2013
@@ -149,9 +149,9 @@ public class EnhNode extends Polymorphic
     @Override protected <X extends RDFNode> X convertTo( Class<X> t ) 
         {
         EnhGraph eg = getGraph();
-        if (eg == null) throw new UnsupportedPolymorphismException( this, t );
+        if (eg == null) throw new UnsupportedPolymorphismException( this, false, t );
         Implementation imp = getPersonality().getImplementation( t );
-        if (imp == null) throw new UnsupportedPolymorphismException( this, t );
+        if (imp == null) throw new UnsupportedPolymorphismException( this, true, t );
         EnhNode result = imp.wrap( asNode(), eg );          
         this.addView( result );
         return t.cast( result );

Modified: jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/UnsupportedPolymorphismException.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/UnsupportedPolymorphismException.java?rev=1432473&r1=1432472&r2=1432473&view=diff
==============================================================================
--- jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/UnsupportedPolymorphismException.java
(original)
+++ jena/trunk/jena-core/src/main/java/com/hp/hpl/jena/enhanced/UnsupportedPolymorphismException.java
Sat Jan 12 16:59:53 2013
@@ -18,7 +18,7 @@
 
 package com.hp.hpl.jena.enhanced;
 
-import com.hp.hpl.jena.shared.JenaException;
+import com.hp.hpl.jena.shared.JenaException ;
 
 /**
     Exception to throw if an enhanced graph does not support polymorphism
@@ -28,31 +28,25 @@ import com.hp.hpl.jena.shared.JenaExcept
 public class UnsupportedPolymorphismException extends JenaException
     {
     private final Class<?> type;
-    private final EnhNode node;
+    private final Object node;
         
     /**
         Initialise this exception with the node that couldn't be polymorphed and
         the class it couldn't be polymorphed to.
     */
-    public UnsupportedPolymorphismException( EnhNode node, Class<?> type )
+    public UnsupportedPolymorphismException( Object node, boolean hasModel, Class<?>
type )
         {
-        super( constructMessage( node, type ) );
+        super( constructMessage( node, hasModel, type ) );
         this.node = node;
         this.type = type;
         }
 
-    private static String constructMessage( EnhNode node, Class<?> type )
+    private static String constructMessage( Object node, boolean hasModel, Class<?>
type )
         {
         String mainMessage = "cannot convert " + node + " to " + type;
-        return node.getGraph() == null ? mainMessage : mainMessage + " -- it has no model";
+        return hasModel ? mainMessage : mainMessage + " -- it has no model";
         }
 
-    /** 
-        Answer the (enhanced) Graph of the node that couldn't be polymorphed;
-        may be null if that node had no attached model.   
-    */
-    public EnhGraph getBadGraph() 
-        { return node.getGraph(); }
     
     /** 
         Answer the class that the node couldn't be polymorphed to

Modified: jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/enhanced/test/TestPackage.java
URL: http://svn.apache.org/viewvc/jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/enhanced/test/TestPackage.java?rev=1432473&r1=1432472&r2=1432473&view=diff
==============================================================================
--- jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/enhanced/test/TestPackage.java (original)
+++ jena/trunk/jena-core/src/test/java/com/hp/hpl/jena/enhanced/test/TestPackage.java Sat
Jan 12 16:59:53 2013
@@ -469,9 +469,9 @@ public class TestPackage extends GraphTe
             fail( "oops" ); 
             }
         catch (UnsupportedPolymorphismException e) 
-            {
+            {    	
             assertEquals( en, e.getBadNode() );
-            assertTrue( "exception should have cuplprit graph", eg == e.getBadGraph() );
+            assertTrue( "exception should have cuplprit graph", eg == ((EnhNode)e.getBadNode()).getGraph()
);
             assertSame( "exception should have culprit class", Property.class, e.getBadClass()
);
             }
         }
@@ -506,7 +506,8 @@ public class TestPackage extends GraphTe
             fail( "should throw UnsupportedPolymorphismException" ); }
         catch (UnsupportedPolymorphismException e) 
             {
-            assertEquals( null, e.getBadGraph() );
+        	assertTrue( e.getBadNode() instanceof EnhNode );
+            assertEquals( null, ((EnhNode)e.getBadNode()).getGraph() );
             assertEquals( Example.class, e.getBadClass() );
             }
         }



Mime
View raw message