devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From re...@apache.org
Subject svn commit: r1693751 - /devicemap/trunk/clients/2.0/reference/src/
Date Sat, 01 Aug 2015 18:29:29 GMT
Author: rezan
Date: Sat Aug  1 18:29:28 2015
New Revision: 1693751

URL: http://svn.apache.org/r1693751
Log:
fixes

Modified:
    devicemap/trunk/clients/2.0/reference/src/AttributeTransformer.java
    devicemap/trunk/clients/2.0/reference/src/Attributes.java
    devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java
    devicemap/trunk/clients/2.0/reference/src/TransformerIsNumber.java
    devicemap/trunk/clients/2.0/reference/src/TransformerReplaceAll.java
    devicemap/trunk/clients/2.0/reference/src/TransformerReplaceFirst.java
    devicemap/trunk/clients/2.0/reference/src/TransformerSplitAndGet.java
    devicemap/trunk/clients/2.0/reference/src/TransformerSubstring.java

Modified: devicemap/trunk/clients/2.0/reference/src/AttributeTransformer.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/AttributeTransformer.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/AttributeTransformer.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/AttributeTransformer.java Sat Aug  1 18:29:28
2015
@@ -70,4 +70,9 @@ public class AttributeTransformer {
   public String getDefaultValue() {
     return defaultValue;
   }
+
+  @Override
+  public String toString() {
+    return "{defaultValue: '" + defaultValue + "' transformer(s): " + transformers + "}";
+  }
 }

Modified: devicemap/trunk/clients/2.0/reference/src/Attributes.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/Attributes.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/Attributes.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/Attributes.java Sat Aug  1 18:29:28 2015
@@ -51,6 +51,10 @@ public class Attributes {
         String key = j.next();
         String value = json.get("attributes").get(key).asText();
 
+        if(key.isEmpty()) {
+          throw new Exception("Empty attribute name not allowed for " + patternId);
+        }
+
         attributeMap.put(key, value);
       }
     }
@@ -97,9 +101,8 @@ public class Attributes {
 
         custom.put(key, value);
       } catch(Exception e) {
-        String errorValue = attributeTransformer.getDefaultValue();
-
-        custom.put(key + "_error", errorValue);
+        custom.put(key, attributeTransformer.getDefaultValue());
+        custom.put(key + "_error", e.toString());
       }
     }
 
@@ -108,8 +111,8 @@ public class Attributes {
 
   @Override
   public String toString() {
-    return "Attribute patternId: " + patternId + ", attribute(s): " + attributes.size() +
-        (attributeTransformers.size() > 0 ? " attributeTransformer(s): " + attributeTransformers.size()
: "");
+    return "Attribute patternId: " + patternId + ", attribute(s): " + attributes +
+        (attributeTransformers.size() > 0 ? " attributeTransformer(s): " + attributeTransformers
: "");
   }
 
   public String getPatternId() {

Modified: devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/DeviceMapClient.java Sat Aug  1 18:29:28 2015
@@ -203,6 +203,12 @@ public class DeviceMapClient {
 
       Main.log("Found " + patternCount + " pattern(s), total: " + patterns.size(), 1);
     }
+
+    //OPTIONAL ATTRIBUTES IN PATTERN FILE
+    
+    if(JsonFile.get(patternFile.getJsonNode(), "attributes").isArray()) {
+      loadAttributes(patternFile);
+    }
   }
 
   public void loadAttributes(JsonFile attributeFile) throws Exception {
@@ -378,6 +384,8 @@ public class DeviceMapClient {
         }
       }
 
+      Main.log("Attribute map: " + attributeMap, 3);
+
       return attributeMap;
     }
 
@@ -386,6 +394,8 @@ public class DeviceMapClient {
 
     custom.put("patternId", patternId);
 
+    Main.log("Attribute map: " + custom, 3);
+
     return Collections.unmodifiableMap(custom);
   }
 
@@ -438,12 +448,16 @@ public class DeviceMapClient {
       return new TransformerLowerCase();
     } else if(type.equals("UpperCase")) {
       return new TransformerUpperCase();
+    } else if(type.equals("ReplaceFirst")) {
+      return new TransformerReplaceFirst(parameters);
     } else if(type.equals("ReplaceAll")) {
       return new TransformerReplaceAll(parameters);
     } else if(type.equals("SplitAndGet")) {
       return new TransformerSplitAndGet(parameters);
     } else if(type.equals("IsNumber")) {
       return new TransformerIsNumber();
+    } else if(type.equals("Substring")) {
+      return new TransformerSubstring(parameters);
     }
 
     throw new Exception("Transformer not found: " + type);

Modified: devicemap/trunk/clients/2.0/reference/src/TransformerIsNumber.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/TransformerIsNumber.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/TransformerIsNumber.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/TransformerIsNumber.java Sat Aug  1 18:29:28
2015
@@ -23,7 +23,7 @@ public class TransformerIsNumber impleme
     try {
       Double.parseDouble(input);
     } catch(NumberFormatException nfe) {
-      throw new Exception(nfe.getMessage());
+      throw new Exception(nfe.toString());
     }
     
     return input;

Modified: devicemap/trunk/clients/2.0/reference/src/TransformerReplaceAll.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/TransformerReplaceAll.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/TransformerReplaceAll.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/TransformerReplaceAll.java Sat Aug  1 18:29:28
2015
@@ -43,6 +43,6 @@ public class TransformerReplaceAll imple
 
   @Override
   public String toString() {
-    return "TransformerReplaceAll, find: '" + find + "', replaceWith: '" + replaceWith +
"'";
+    return "TransformerReplaceAll  find: '" + find + "'  replaceWith: '" + replaceWith +
"'";
   }
 }

Modified: devicemap/trunk/clients/2.0/reference/src/TransformerReplaceFirst.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/TransformerReplaceFirst.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/TransformerReplaceFirst.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/TransformerReplaceFirst.java Sat Aug  1 18:29:28
2015
@@ -49,6 +49,6 @@ public class TransformerReplaceFirst imp
 
   @Override
   public String toString() {
-    return "TransformerReplaceFirst, find: '" + find + "', replaceWith: '" + replaceWith
+ "'";
+    return "TransformerReplaceFirst  find: '" + find + "'  replaceWith: '" + replaceWith
+ "'";
   }
 }

Modified: devicemap/trunk/clients/2.0/reference/src/TransformerSplitAndGet.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/TransformerSplitAndGet.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/TransformerSplitAndGet.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/TransformerSplitAndGet.java Sat Aug  1 18:29:28
2015
@@ -64,6 +64,6 @@ public class TransformerSplitAndGet impl
 
   @Override
   public String toString() {
-    return "SplitAndGet, delimeter: '" + delimeter + "', get: " + get;
+    return "SplitAndGet  delimeter: '" + delimeter + "'  get: " + get;
   }
 }

Modified: devicemap/trunk/clients/2.0/reference/src/TransformerSubstring.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/clients/2.0/reference/src/TransformerSubstring.java?rev=1693751&r1=1693750&r2=1693751&view=diff
==============================================================================
--- devicemap/trunk/clients/2.0/reference/src/TransformerSubstring.java (original)
+++ devicemap/trunk/clients/2.0/reference/src/TransformerSubstring.java Sat Aug  1 18:29:28
2015
@@ -62,6 +62,6 @@ public class TransformerSubstring implem
 
   @Override
   public String toString() {
-    return "TransformerSubstring, start: '" + start + (maxLength >= 0 ? "', maxLength:
" + maxLength : "");
+    return "TransformerSubstring  start: '" + start + (maxLength >= 0 ? "'  maxLength:
" + maxLength : "");
   }
 }



Mime
View raw message