incubator-droids-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thors...@apache.org
Subject svn commit: r1446768 - in /incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids: core/AbstractData.java core/ContentEntity.java core/Data.java core/ParserData.java handle/SysoutHandler.java parse/LinkedParserData.java
Date Fri, 15 Feb 2013 21:08:12 GMT
Author: thorsten
Date: Fri Feb 15 21:08:11 2013
New Revision: 1446768

URL: http://svn.apache.org/r1446768
Log:
Refactoring AbstractData to be more open to generic Object instead to limit the usage to string.

Modified:
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractData.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Data.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ParserData.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
    incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/parse/LinkedParserData.java

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractData.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractData.java?rev=1446768&r1=1446767&r2=1446768&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractData.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/AbstractData.java
Fri Feb 15 21:08:11 2013
@@ -24,23 +24,23 @@ import java.util.Map;
  */
 public abstract class AbstractData implements Data {
 
-    private Map<String, String[]> data = null;
+    private Map<String, Object[]> data = null;
 
     /**
      * Constructs a new, empty parser data.
      */
     public AbstractData() {
-        data = new HashMap<String, String[]>();
+        data = new HashMap<String, Object[]>();
     }
 
     @Override
-    public String[] names() {
+    public Object[] names() {
         return data.keySet().toArray(new String[data.keySet().size()]);
     }
 
     @Override
-    public String get(final String name) {
-        String[] values = data.get(name);
+    public Object get(final String name) {
+        Object[] values = data.get(name);
         if (values == null) {
             return null;
         } else {
@@ -49,24 +49,24 @@ public abstract class AbstractData imple
     }
 
     @Override
-    public String[] getValues(final String name) {
-        String[] values = data.get(name);
+    public Object[] getValues(final String name) {
+        Object[] values = data.get(name);
         if (values == null) {
             values = new String[0];
         }
         return values;
     }
 
-    private String[] appendedValues(String[] values, final String value) {
-        String[] newValues = new String[values.length + 1];
+    private Object[] appendedValues(Object[] values, final Object value) {
+        Object[] newValues = new Object[values.length + 1];
         System.arraycopy(values, 0, newValues, 0, values.length);
         newValues[newValues.length - 1] = value;
         return newValues;
     }
 
     @Override
-    public void add(final String name, final String value) {
-        String[] values = data.get(name);
+    public void add(final String name, final Object value) {
+        Object[] values = data.get(name);
         if (values == null) {
             set(name, value);
         } else {
@@ -75,16 +75,16 @@ public abstract class AbstractData imple
     }
 
     @Override
-    public void set(String name, String value) {
+    public void set(String name, Object value) {
         if (value != null) {
-            data.put(name, new String[]{value});
+            data.put(name, new Object[]{value});
         } else {
             data.remove(name);
         }
     }
 
     @Override
-    public void set(String name, String[] value) {
+    public void set(String name, Object[] value) {
         if (value != null) {
             data.put(name, value);
         } else {

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java?rev=1446768&r1=1446767&r2=1446768&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ContentEntity.java
Fri Feb 15 21:08:11 2013
@@ -69,7 +69,7 @@ public class ContentEntity extends Abstr
      * @return the charset
      */
     public String getCharset() {
-        return this.get(CHARSET);
+        return (String) this.get(CHARSET);
     }
 
     /**
@@ -87,7 +87,7 @@ public class ContentEntity extends Abstr
      * @return the length of the content.
      */
     public long getContentLength() throws NumberFormatException {
-        return Long.parseLong(this.get(CONTENT_LENGTH));
+        return Long.parseLong((String) this.get(CONTENT_LENGTH));
     }
 
     /**
@@ -105,7 +105,7 @@ public class ContentEntity extends Abstr
      * @return the content type
      */
     public String getContentType() {
-        return this.get(CONTENT_TYPE);
+        return (String) this.get(CONTENT_TYPE);
     }
 
     /**

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Data.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Data.java?rev=1446768&r1=1446767&r2=1446768&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Data.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/Data.java
Fri Feb 15 21:08:11 2013
@@ -28,7 +28,7 @@ public interface Data {
      *
      * @return data names
      */
-    public String[] names();
+    public Object[] names();
 
     /**
      * Set data name/value. Associate the specified value to the specified
@@ -39,7 +39,7 @@ public interface Data {
      * @param name the data name.
      * @param value  the data value, or <code>null</code>
      */
-    public void set(final String name, final String value);
+    public void set(final String name, final Object value);
 
     /**
      * Set multiple values for a name.
@@ -48,7 +48,7 @@ public interface Data {
      * @param name the data name
      * @param value the data value
      */
-    public void set(final String name, final String[] value);
+    public void set(final String name, final Object[] value);
 
     /**
      * Add a data name/value mapping. Add the specified value to the list of
@@ -57,7 +57,7 @@ public interface Data {
      * @param name the data name.
      * @param value the data value.
      */
-    public void add(final String name, final String value);
+    public void add(final String name, final Object value);
 
     /**
      * Get the value associated to a data name. If many values are associated
@@ -66,7 +66,7 @@ public interface Data {
      * @param name of the data.
      * @return the value associated to the specified data name.
      */
-    public String get(final String name);
+    public Object get(final String name);
 
     /**
      * Get the values associated to a data name.
@@ -74,6 +74,6 @@ public interface Data {
      * @param name of the data.
      * @return the values associated to a data name.
      */
-    public String[] getValues(final String name);
+    public Object[] getValues(final String name);
 
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ParserData.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ParserData.java?rev=1446768&r1=1446767&r2=1446768&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ParserData.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/core/ParserData.java
Fri Feb 15 21:08:11 2013
@@ -34,6 +34,6 @@ public class ParserData extends Abstract
     }
 
     public String getText() {
-        return this.get(TEXT);
+        return (String) this.get(TEXT);
     }
 }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java?rev=1446768&r1=1446767&r2=1446768&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/handle/SysoutHandler.java
Fri Feb 15 21:08:11 2013
@@ -68,7 +68,7 @@ public class SysoutHandler extends Write
             ContentEntity contentEntity = task.getContentEntity();
             if (contentEntity != null) {
                 logger.info("########## " + HEADERS + " ##########");
-                for (String key : contentEntity.names()) {
+                for (String key : (String []) contentEntity.names()) {
                     logger.info(key + ": " + contentEntity.get(key));
                 }
             }
@@ -77,7 +77,7 @@ public class SysoutHandler extends Write
             ParserData parserData = task.getParserData();
             if (parserData != null) {
                 logger.info("########## " + PARSERDATA + " ##########");
-                for (String key : parserData.names()) {
+                for (String key : (String []) parserData.names()) {
                     logger.info(key + ": " + parserData.get(key));
                 }
             }

Modified: incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/parse/LinkedParserData.java
URL: http://svn.apache.org/viewvc/incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/parse/LinkedParserData.java?rev=1446768&r1=1446767&r2=1446768&view=diff
==============================================================================
--- incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/parse/LinkedParserData.java
(original)
+++ incubator/droids/branches/0.2.x-cleanup/droids-core/src/main/java/org/apache/droids/parse/LinkedParserData.java
Fri Feb 15 21:08:11 2013
@@ -36,7 +36,7 @@ public class LinkedParserData extends Pa
     }
 
     public String getAnchorText() {
-        return this.get(ANCHOR_TEXT);
+        return (String) this.get(ANCHOR_TEXT);
     }
 
     public void setAnchorTitle(String anchorTitle) {
@@ -44,7 +44,7 @@ public class LinkedParserData extends Pa
     }
 
     public String getAnchorTitle() {
-        return this.get(ANCHOR_TITLE);
+        return (String) this.get(ANCHOR_TITLE);
     }
 
 }



Mime
View raw message