abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r532147 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/ core/src/main/resources/org/ parser/src/main/java/org/apache/abdera/parser/stax/
Date Wed, 25 Apr 2007 00:05:15 GMT
Author: jmsnell
Date: Tue Apr 24 17:05:14 2007
New Revision: 532147

URL: http://svn.apache.org/viewvc?view=rev&rev=532147
Log:
 * Remove no longer necessary resource files
 * Utility method to determine if app:categories is "out of line"
 * New DateTimeWrapper and PersonWrapper classes so extensions can create derivatives of the
Atom Person and Date constructs

Added:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/DateTimeWrapper.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/PersonWrapper.java
Removed:
    incubator/abdera/java/trunk/core/src/main/resources/org/
Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java?view=diff&rev=532147&r1=532146&r2=532147
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Categories.java
Tue Apr 24 17:05:14 2007
@@ -156,5 +156,9 @@
    */
   boolean contains(String term, String scheme) throws IRISyntaxException;
   
+  /**
+   * Returns true if the href attribute is set
+   */
+  boolean isOutOfLine();
 }
 

Added: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/DateTimeWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/DateTimeWrapper.java?view=auto&rev=532147
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/DateTimeWrapper.java
(added)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/DateTimeWrapper.java
Tue Apr 24 17:05:14 2007
@@ -0,0 +1,100 @@
+/*
+* 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.model;
+
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+
+public abstract class DateTimeWrapper 
+  extends ElementWrapper 
+  implements DateTime {
+  
+  protected DateTimeWrapper(Element internal) {
+    super(internal);
+  }
+
+  protected DateTimeWrapper(Factory factory, QName qname) {
+    super(factory, qname);
+  }
+
+  public AtomDate getValue() {
+    AtomDate value = null;
+    String v = getText();
+    if (v != null) {
+      value = AtomDate.valueOf(v);
+    }
+    return value;
+  }
+
+  public void setValue(AtomDate dateTime) {
+    if (dateTime != null)
+      setText(dateTime.getValue());
+    else 
+      setText("");
+  }
+
+  public void setDate(Date date) {
+    if (date != null)
+      setText(AtomDate.valueOf(date).getValue());
+    else 
+      setText("");
+  }
+
+  public void setCalendar(Calendar date) {
+    if (date != null)
+      setText(AtomDate.valueOf(date).getValue());
+    else 
+      setText("");
+  }
+
+  public void setTime(long date) {
+    setText(AtomDate.valueOf(date).getValue());
+  }
+
+  public void setString(String date) {
+    if (date != null)
+      setText(AtomDate.valueOf(date).getValue());
+    else 
+      setText("");
+  }
+
+  public Date getDate() {
+    AtomDate ad = getValue();
+    return (ad != null) ? ad.getDate() : null;
+  }
+
+  public Calendar getCalendar() {
+    AtomDate ad = getValue();
+    return (ad != null) ? ad.getCalendar() : null;
+  }
+
+  public long getTime() {
+    AtomDate ad = getValue();
+    return (ad != null) ? ad.getTime() : null;
+  }
+
+  public String getString() {
+    AtomDate ad = getValue();
+    return (ad != null) ? ad.getValue() : null;
+  }
+
+}

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java?view=diff&rev=532147&r1=532146&r2=532147
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/ExtensibleElementWrapper.java
Tue Apr 24 17:05:14 2007
@@ -23,7 +23,7 @@
 
 import org.apache.abdera.factory.Factory;
 
-public class ExtensibleElementWrapper 
+public abstract class ExtensibleElementWrapper 
   extends ElementWrapper 
   implements ExtensibleElement {
 
@@ -35,7 +35,7 @@
     super(factory, qname);
   }
 
-  private ExtensibleElement getExtInternal() {
+  protected ExtensibleElement getExtInternal() {
     return (ExtensibleElement) getInternal();
   }
   

Added: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/PersonWrapper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/PersonWrapper.java?view=auto&rev=532147
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/PersonWrapper.java
(added)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/PersonWrapper.java
Tue Apr 24 17:05:14 2007
@@ -0,0 +1,132 @@
+/*
+* 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.model;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.i18n.iri.IRISyntaxException;
+import org.apache.abdera.util.Constants;
+
+public abstract class PersonWrapper 
+  extends ExtensibleElementWrapper
+  implements Person, Constants {
+  
+  protected PersonWrapper(Element internal) {
+    super(internal);
+  }
+  
+  public PersonWrapper(Factory factory, QName qname) {
+    super(factory, qname);
+  }
+  
+  public String getEmail() {
+    Element email = getEmailElement();
+    return (email != null) ? email.getText() : null;
+  }
+
+  public Element getEmailElement() {
+    return getInternal().getFirstChild(EMAIL);
+  }
+
+  public String getName() {
+    Element name = getNameElement();
+    return (name != null) ? name.getText() : null;
+  }
+
+  public Element getNameElement() {
+    return getInternal().getFirstChild(NAME);
+  }
+
+  public IRI getUri() throws IRISyntaxException {
+    IRIElement iri = getUriElement();
+    return (iri != null) ? iri.getResolvedValue() : null;
+  }
+
+  public IRIElement getUriElement() {
+    return getInternal().getFirstChild(URI);
+  }
+
+  public Element setEmail(String email) {
+    ExtensibleElement internal = getExtInternal();
+    Element el = getEmailElement();
+    if (email != null) {
+      if (el == null)
+        el = internal.getFactory().newEmail(internal);
+      el.setText(email);
+      return el;
+    } else {
+      if (el != null) el.discard();
+      return null;
+    }
+  }
+
+  public void setEmailElement(Element element) {
+    ExtensibleElement internal = getExtInternal();
+    Element el = getEmailElement();
+    if (el != null) el.discard();
+    if (element != null) 
+      internal.addExtension(element);
+  }
+
+  public Element setName(String name) {
+    ExtensibleElement internal = getExtInternal();
+    Element el = getNameElement();
+    if (name != null) {
+      if (el == null)
+        el = internal.getFactory().newName(internal);
+      el.setText(name);
+      return el;
+    } else {
+      if (el != null) el.discard();
+      return null;
+    }
+  }
+
+  public void setNameElement(Element element) {
+    ExtensibleElement internal = getExtInternal();
+    Element el = getNameElement();
+    if (el != null) el.discard();
+    if (element != null) 
+      internal.addExtension(element);
+  }
+
+  public IRIElement setUri(String uri) throws IRISyntaxException {
+    ExtensibleElement internal = getExtInternal();
+    IRIElement el = getUriElement();
+    if (uri != null) {
+      if (el == null)
+        el = internal.getFactory().newUri(internal);
+      el.setText(uri.toString());
+      return el;
+    } else {
+      if (el != null) el.discard();
+      return null;
+    }
+  }
+
+  public void setUriElement(IRIElement element) {
+    ExtensibleElement internal = getExtInternal();
+    Element el = getUriElement();
+    if (el != null) el.discard();
+    if (element != null) 
+      internal.addExtension(element);
+  }
+
+}

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java?view=diff&rev=532147&r1=532146&r2=532147
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMCategories.java
Tue Apr 24 17:05:14 2007
@@ -210,6 +210,12 @@
     return false;
   }
   
-
+  public boolean isOutOfLine() {
+    boolean answer = false;
+    try {
+      answer = getHref() != null;
+    } catch (Exception e) {}
+    return answer;
+  }
 
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java?view=diff&rev=532147&r1=532146&r2=532147
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMPerson.java
Tue Apr 24 17:05:14 2007
@@ -172,6 +172,6 @@
   
   public IRI getUri() throws IRISyntaxException {
     IRIElement iri = getUriElement();
-    return (iri != null) ? iri.getValue() : null;
+    return (iri != null) ? iri.getResolvedValue() : null;
   }
 }



Mime
View raw message