tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rf...@apache.org
Subject svn commit: r562302 - in /incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy: Intent.java impl/IntentImpl.java
Date Fri, 03 Aug 2007 00:30:53 GMT
Author: rfeng
Date: Thu Aug  2 17:30:52 2007
New Revision: 562302

URL: http://svn.apache.org/viewvc?view=rev&rev=562302
Log:
Add more metadata to the IntentImpl

Modified:
    incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
    incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java

Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java?view=diff&rev=562302&r1=562301&r2=562302
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
(original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/Intent.java
Thu Aug  2 17:30:52 2007
@@ -45,6 +45,18 @@
     void setName(QName name);
 
     /**
+     * Get the intent domain (the root intent name before any qualifiers)
+     * @return the domain
+     */
+    String getDomain();
+
+    /**
+     * Get the intent qualifiers
+     * @return the domain
+     */
+    String[] getQualifiedNames();
+
+    /**
      * Returns the list of operations that this intent applies to.
      * 
      * @return
@@ -60,11 +72,18 @@
     List<QName> getConstrains();
 
     /**
+     * Returns the list of required intents.
+     * 
+     * @return
+     */
+    List<Intent> getRequiredIntents();
+
+    /**
      * Returns the list of children qualified intents.
      * 
      * @return the list of children qualified intents.
      */
-    //List<Intent> getQualifiedIntents();
+    List<Intent> getQualifiedIntents();
 
     /**
      * Returns the intent description.

Modified: incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java?view=diff&rev=562302&r1=562301&r2=562302
==============================================================================
--- incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/policy/src/main/java/org/apache/tuscany/sca/policy/impl/IntentImpl.java
Thu Aug  2 17:30:52 2007
@@ -33,13 +33,18 @@
  */
 public class IntentImpl implements Intent {
 
+    private static final String QUALIFIED_SEPARATOR = ".";
+    private static final String DOMAIN_SEPARATOR = ".";
     private QName name;
     private List<Operation> operations = new ArrayList<Operation>();
-    private List<QName> constrains = new ArrayList<QName>();
+    private List<QName> constrains;
     private String description;
-    //private List<Intent> qualifiedIntents;
-    private boolean unresolved = true;
-    
+    private List<Intent> qualifiedIntents;
+    private List<Intent> requiredIntents;
+    private boolean unresolved;
+    private String domain;
+    private String[] qualifiedNames;
+
     protected IntentImpl() {
     }
 
@@ -49,6 +54,25 @@
 
     public void setName(QName name) {
         this.name = name;
+        String iname = name.getLocalPart();
+        int domainIdx = iname.indexOf(DOMAIN_SEPARATOR);
+        if (domainIdx > -1) {
+            domain = iname.substring(0, domainIdx);
+            String qualifNamesStr = iname.substring(domainIdx + 1);
+            String pattern = "\\" + QUALIFIED_SEPARATOR;
+            qualifiedNames = qualifNamesStr.split(pattern);
+        } else
+            domain = iname;
+    }
+
+    public String getDomain() {
+        return domain;
+    }
+
+    public String[] getQualifiedNames() {
+        String[] results = new String[qualifiedNames.length];
+        System.arraycopy(qualifiedNames, 0, results, 0, qualifiedNames.length);
+        return results;
     }
 
     public List<Operation> getOperations() {
@@ -67,9 +91,13 @@
         this.description = description;
     }
 
-    /*public List<Intent> getQualifiedIntents() {
+    public List<Intent> getQualifiedIntents() {
         return qualifiedIntents;
-    }*/
+    }
+
+    public List<Intent> getRequiredIntents() {
+        return requiredIntents;
+    }
 
     public boolean isUnresolved() {
         return unresolved;
@@ -78,24 +106,20 @@
     public void setUnresolved(boolean unresolved) {
         this.unresolved = unresolved;
     }
-    
-    @Override
-    public int hashCode() {
-        return String.valueOf(getName()).hashCode();
-    }
-    
-    @Override
+
     public boolean equals(Object obj) {
         if (obj == this) {
             return true;
-        } else if (obj instanceof Intent) {
-            if (getName() != null) {
-                return getName().equals(((Intent)obj).getName());
+        } else {
+            if (obj instanceof IntentImpl) {
+                if (getName() != null) {
+                    return getName().equals(((IntentImpl)obj).getName());
+                } else {
+                    return ((IntentImpl)obj).getName() == null;
+                }
             } else {
-                return ((Intent)obj).getName() == null;
+                return false;
             }
-        } else {
-            return false;
         }
     }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message