abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r441213 - in /incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera: parser/NamedParser.java util/AbstractNamedParser.java util/AbstractNamedWriter.java
Date Thu, 07 Sep 2006 20:35:50 GMT
Author: jmsnell
Date: Thu Sep  7 13:35:49 2006
New Revision: 441213

URL: http://svn.apache.org/viewvc?view=rev&rev=441213
Log:
Add an abstract NamedParser base implementation.  
Add support for checking to see if a NamedParser can handle a given media type
Make the name and format lists of both AbstractNamedParser and AbstractNamedWriter immutable

Added:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedWriter.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java?view=diff&rev=441213&r1=441212&r2=441213
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/NamedParser.java
Thu Sep  7 13:35:49 2006
@@ -21,4 +21,14 @@
 
   String getName();
   
+  /**
+   * Return the media type of the format consumed by this parser
+   */
+  String[] getInputFormats();
+  
+  /**
+   * Returns true if the format consumed by this parser matches the specified
+   * media type
+   */
+  boolean parsesFormat(String mediatype);
 }

Added: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java?view=auto&rev=441213
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
(added)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedParser.java
Thu Sep  7 13:35:49 2006
@@ -0,0 +1,49 @@
+/*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements.  The ASF licenses this file to You
+* under the Apache License, Version 2.0 (the "License"); you may not
+* use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.  For additional information regarding
+* copyright in this work, please see the NOTICE file in the top level
+* directory of this distribution.
+*/
+package org.apache.abdera.util;
+
+import org.apache.abdera.parser.NamedParser;
+
+public abstract class AbstractNamedParser 
+  extends AbstractParser 
+  implements NamedParser {
+
+  protected final String name;
+  protected final String[] formats;
+  
+  protected AbstractNamedParser(String name, String... formats) {
+    this.name = name;
+    this.formats = formats;
+  }
+  
+  public String getName() {
+    return name;
+  }
+
+  public String[] getInputFormats() {
+    return formats;
+  }
+
+  public boolean parsesFormat(String mediatype) {
+    for (String format : formats) {
+      if (MimeTypeHelper.isMatch(format, mediatype))
+        return true;
+    }
+    return false;
+  }
+}

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedWriter.java?view=diff&rev=441213&r1=441212&r2=441213
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedWriter.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractNamedWriter.java
Thu Sep  7 13:35:49 2006
@@ -22,10 +22,10 @@
 public abstract class AbstractNamedWriter 
   implements NamedWriter {
 
-  protected String name = null;
-  protected String[] formats = null;
+  protected final String name;
+  protected final String[] formats;
   
-  protected AbstractNamedWriter(String name, String[] formats ) {
+  protected AbstractNamedWriter(String name, String... formats ) {
     this.name = name;
     this.formats = formats;
   }



Mime
View raw message