You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@abdera.apache.org by jm...@apache.org on 2008/01/28 22:26:05 UTC

svn commit: r616050 [3/3] - in /incubator/abdera/java/trunk/extensions/converters: ./ src/main/java/org/apache/abdera/converter/ src/main/java/org/apache/abdera/ext/ src/main/java/org/apache/abdera/ext/serializer/ src/main/java/org/apache/abdera/ext/se...

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategoriesSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategoriesSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategoriesSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategoriesSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,42 @@
+/*
+* 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.ext.serializer.impl;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Category;
+import org.apache.abdera.util.Constants;
+
+public class CategoriesSerializer 
+  extends ElementSerializer {
+
+  public CategoriesSerializer() {
+    super(Constants.CATEGORIES);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+      writeElements(Category.class, new CategorySerializer(), source, objectContext, context, conventions);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategorySerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategorySerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategorySerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CategorySerializer.java Mon Jan 28 13:26:00 2008
@@ -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.ext.serializer.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Category;
+import org.apache.abdera.ext.serializer.annotation.Label;
+import org.apache.abdera.ext.serializer.annotation.Scheme;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
+
+public class CategorySerializer 
+  extends ElementSerializer {
+
+  public CategorySerializer() {
+    super(Constants.CATEGORY);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+    
+    StreamWriter sw = context.getStreamWriter();
+    Category _category = objectContext.getAnnotation(Category.class);
+    
+    String scheme = null;
+    AccessibleObject accessor = objectContext.getAccessor(Scheme.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        scheme = toString(value);
+    }
+    if (scheme == null) {
+      Scheme _scheme = objectContext.getAnnotation(Scheme.class);
+      if (_scheme != null && !_scheme.value().equals(DEFAULT)) {
+        scheme = _scheme.value();
+      }
+    }
+    if (scheme == null && _category != null && !_category.scheme().equals(DEFAULT)) {
+      scheme = _category.scheme();
+    }
+    if (scheme != null)
+      sw.writeAttribute("scheme", scheme);
+
+    String label = null;
+    accessor = objectContext.getAccessor(Label.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        label = toString(value);
+    }
+    if (label == null) {
+      Label _label = objectContext.getAnnotation(Label.class);
+      if (_label != null && !_label.value().equals(DEFAULT)) {
+        label = _label.value();
+      }
+    }
+    if (label == null && _category != null && !_category.label().equals(DEFAULT)) {
+      label = _category.label();
+    }
+    if (label != null)
+      sw.writeAttribute("label", label);
+    
+    String term = null;
+    accessor = objectContext.getAccessor(Value.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        term = toString(value);
+    }
+    if (term == null) term = toString(source);
+    if (term != null) 
+      sw.writeAttribute("term", term);
+    
+    writeAttributes(source, objectContext, context, conventions);
+    writeExtensions(source, objectContext, context, conventions);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CollectionSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CollectionSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CollectionSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/CollectionSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,46 @@
+/*
+* 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.ext.serializer.impl;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Accept;
+import org.apache.abdera.ext.serializer.annotation.Categories;
+import org.apache.abdera.ext.serializer.annotation.Title;
+import org.apache.abdera.util.Constants;
+
+public class CollectionSerializer 
+  extends ElementSerializer {
+
+  public CollectionSerializer() {
+    super(Constants.COLLECTION);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      writeElement(Title.class, new TextSerializer(Constants.TITLE), source, objectContext, context, conventions);
+      writeElements(Accept.class, new SimpleElementSerializer(Constants.ACCEPT), source, objectContext, context, conventions);
+      writeElements(Categories.class, new CategoriesSerializer(), source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ContentSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ContentSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ContentSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ContentSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,142 @@
+/*
+* 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.ext.serializer.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+import java.lang.reflect.AccessibleObject;
+
+import javax.activation.DataHandler;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.SerializationException;
+import org.apache.abdera.ext.serializer.annotation.Content;
+import org.apache.abdera.ext.serializer.annotation.MediaType;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.model.Div;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Content.Type;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
+
+public class ContentSerializer 
+  extends ElementSerializer {
+
+  public ContentSerializer() {
+    super(Constants.CONTENT);
+  }
+
+  protected void init(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+    
+  }
+  
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      
+      Type type = Type.TEXT;
+      Object contentValue = null;
+      ObjectContext valueContext = null;
+      AccessibleObject accessor = objectContext.getAccessor(Value.class, conventions);
+      if (accessor != null && !(source instanceof Element)) {
+        contentValue = eval(accessor, source);
+        valueContext = new ObjectContext(contentValue,source,accessor);
+        Content _content = valueContext.getAnnotation(Content.class);
+        type = _content != null ? _content.type() : type;
+      } else {
+        Content _content = objectContext.getAnnotation(Content.class);
+        type = _content != null ? _content.type() : type;
+        contentValue = source;
+        valueContext = objectContext;
+      }
+      
+      StreamWriter sw = context.getStreamWriter();
+      sw.startContent(type);
+      writeAttributes(
+          source, 
+          objectContext, 
+          context, 
+          conventions);
+
+      if (type == Type.MEDIA || type == Type.XML) {
+      String mediatype = null;
+      AccessibleObject mtaccessor = valueContext.getAccessor(MediaType.class, conventions);
+      if (mtaccessor != null) {
+        Object mtvalue = eval(mtaccessor,contentValue);
+        mediatype = mtvalue != null ? toString(mtvalue) : null;
+      }
+      if (mediatype == null) {
+        MediaType mt = valueContext.getAnnotation(MediaType.class);
+        mediatype = mt != null && !mt.value().equals(DEFAULT) ? mt.value() : null;
+      }
+      if (mediatype != null) 
+        sw.writeAttribute("type", mediatype);
+      }
+      
+      switch(type) {
+        case TEXT:
+        case HTML:
+          sw.writeElementText(toString(contentValue));
+          break;
+        case XHTML:
+          Div div = null;
+          if (contentValue instanceof Div)
+            div = (Div) contentValue;
+          else {
+            div = context.getAbdera().getFactory().newDiv();
+            div.setValue(toString(contentValue));
+          } 
+          context.serialize(div, new ObjectContext(div));
+          break;
+        case XML:
+          Element el = null;
+          if (contentValue instanceof Element)
+            el = (Element) contentValue;
+          else {
+            StringReader sr = new StringReader(toString(contentValue));
+            Document<Element> doc = context.getAbdera().getParser().parse(sr);
+            el = doc.getRoot();
+          } 
+          context.serialize(el, new ObjectContext(el));
+          break;
+        case MEDIA:
+          try {
+            if (contentValue instanceof DataHandler)
+              sw.writeElementText((DataHandler)contentValue);
+            else if (contentValue instanceof InputStream)
+              sw.writeElementText((InputStream)contentValue);
+            else 
+              sw.writeElementText(toString(contentValue));
+          } catch (IOException e) {
+            throw new SerializationException(e);
+          }
+      }      
+  }
+  
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ControlSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ControlSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ControlSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ControlSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,59 @@
+/*
+* 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.ext.serializer.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.Serializer;
+import org.apache.abdera.ext.serializer.annotation.Draft;
+import org.apache.abdera.util.Constants;
+
+public class ControlSerializer 
+  extends ElementSerializer {
+
+  public ControlSerializer() {
+    super(Constants.CONTROL);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      AccessibleObject accessor = objectContext.getAccessor(Draft.class, conventions);
+      if (accessor != null) {
+        Object value = eval(accessor,source);
+        if (value instanceof Boolean) {
+          String val = ((Boolean)value).booleanValue() ? "yes" : "no";
+          ObjectContext valueContext = new ObjectContext(val);
+          Serializer ser = new SimpleElementSerializer(Constants.DRAFT);
+          ser.serialize(val, valueContext, context);
+        } else {
+          ObjectContext valueContext = new ObjectContext(value);
+          context.serialize(value, valueContext);
+        }
+      }
+      writeExtensions(source, objectContext, context, conventions);
+  }
+
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/DateTimeSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/DateTimeSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/DateTimeSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/DateTimeSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,102 @@
+/*
+* 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.ext.serializer.impl;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.model.AtomDate;
+import org.apache.abdera.writer.StreamWriter;
+
+public class DateTimeSerializer 
+  extends ElementSerializer {
+
+  public DateTimeSerializer(
+    QName qname) {
+      super(qname);
+  }
+
+  public DateTimeSerializer() {
+    super(null);
+  }
+  
+  protected void init(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      QName qname = this.qname != null ? this.qname : getQName(objectContext.getAccessor());
+      StreamWriter sw = context.getStreamWriter();
+      sw.startElement(qname);
+  }
+  
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+    
+      writeAttributes(
+        source, 
+        objectContext, 
+        context, 
+        conventions);
+      Object value = null;
+      if (!(source instanceof Long)) {
+        AccessibleObject accessor = 
+          objectContext.getAccessor(
+            Value.class, 
+            conventions);
+        if (accessor != null) {
+          value = eval(accessor, source);
+        }
+      }
+      writeValue(
+        value != null ?
+          value :
+          source,
+        context);
+  } 
+  
+  private void writeValue(  
+    Object value,
+    SerializationContext context) {
+      StreamWriter sw = context.getStreamWriter();
+      Date date = null;
+      if (value == null) return;
+      if (value instanceof Date) {
+        date = (Date) value;
+      } else if (value instanceof Calendar) {
+        date = ((Calendar)value).getTime();
+      } else if (value instanceof Long) {
+        date = new Date(((Long)value).longValue());
+      } else if (value instanceof String) {
+        date = AtomDate.parse((String)value);
+      } else {
+        date = AtomDate.parse(value.toString());
+      }
+      sw.writeElementText(date);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ElementSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ElementSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ElementSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ElementSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,61 @@
+/*
+* 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.ext.serializer.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.BaseSerializer;
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.writer.StreamWriter;
+
+public class ElementSerializer
+  extends BaseSerializer {
+
+  protected final QName qname;
+  
+  public ElementSerializer(QName qname) {
+    this.qname = qname;
+  }
+
+  public ElementSerializer() {
+    this.qname = null;
+  }
+  
+  protected void finish(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      context.getStreamWriter().endElement();
+  }
+
+  protected void init(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      QName qname = this.qname != null ? this.qname : getQName(objectContext.getAccessor());
+      StreamWriter sw = context.getStreamWriter();
+      sw.startElement(qname);
+      writeCommon(source, objectContext, context, conventions);
+
+  }
+   
+}
\ No newline at end of file

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/EntrySerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/EntrySerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/EntrySerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/EntrySerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,68 @@
+/*
+* 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.ext.serializer.impl;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Author;
+import org.apache.abdera.ext.serializer.annotation.Category;
+import org.apache.abdera.ext.serializer.annotation.Content;
+import org.apache.abdera.ext.serializer.annotation.Contributor;
+import org.apache.abdera.ext.serializer.annotation.Control;
+import org.apache.abdera.ext.serializer.annotation.Edited;
+import org.apache.abdera.ext.serializer.annotation.ID;
+import org.apache.abdera.ext.serializer.annotation.Link;
+import org.apache.abdera.ext.serializer.annotation.Published;
+import org.apache.abdera.ext.serializer.annotation.Rights;
+import org.apache.abdera.ext.serializer.annotation.Summary;
+import org.apache.abdera.ext.serializer.annotation.Title;
+import org.apache.abdera.ext.serializer.annotation.Updated;
+import org.apache.abdera.util.Constants;
+
+public class EntrySerializer 
+  extends ElementSerializer {
+
+  public EntrySerializer() {
+    super(Constants.ENTRY);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      writeElement (ID.class, new IRISerializer(Constants.ID), source, objectContext, context, conventions);
+      writeElement (Title.class, new TextSerializer(Constants.TITLE), source, objectContext, context, conventions);
+      writeElement (Summary.class, new TextSerializer(Constants.SUMMARY), source, objectContext, context, conventions);      
+      writeElement (Rights.class, new TextSerializer(Constants.RIGHTS), source, objectContext, context, conventions);
+      writeElement (Updated.class, new DateTimeSerializer(Constants.UPDATED), source, objectContext, context, conventions);
+      writeElement (Published.class, new DateTimeSerializer(Constants.PUBLISHED), source, objectContext, context, conventions);
+      writeElement (Edited.class, new DateTimeSerializer(Constants.EDITED), source, objectContext, context, conventions);
+      writeElement (Content.class, new ContentSerializer(), source, objectContext, context, conventions);
+      writeElement (Control.class, new ControlSerializer(), source, objectContext, context, conventions);
+      writeElements(Link.class, new LinkSerializer(), source, objectContext, context, conventions);
+      writeElements(Category.class, new CategorySerializer(), source, objectContext, context, conventions);
+      writeElements(Author.class, new PersonSerializer(Constants.AUTHOR), source, objectContext, context, conventions);
+      writeElements(Contributor.class, new PersonSerializer(Constants.CONTRIBUTOR), source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+  }
+
+   
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ExtensionSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ExtensionSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ExtensionSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ExtensionSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,46 @@
+/*
+* 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.ext.serializer.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+
+public class ExtensionSerializer 
+  extends ElementSerializer {
+
+  public ExtensionSerializer() {
+    super(null);
+  }
+  
+  public ExtensionSerializer(QName qname) {
+    super(qname);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FOMSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FOMSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FOMSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FOMSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,86 @@
+/*
+* 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.ext.serializer.impl;
+
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.BaseSerializer;
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.model.Comment;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ProcessingInstruction;
+import org.apache.abdera.model.TextValue;
+import org.apache.abdera.writer.StreamWriter;
+import org.apache.abdera.xpath.XPath;
+
+public class FOMSerializer 
+  extends BaseSerializer {
+  
+  public FOMSerializer() {}
+  
+  protected void finish(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {}
+  
+  protected void init(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {}
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      StreamWriter sw = context.getStreamWriter();
+      if (!(source instanceof Element)) return;
+      Element element = (Element) source;
+      sw.startElement(element.getQName());
+      for (QName attr : element.getAttributes())
+        sw.writeAttribute(
+          attr, 
+          element.getAttributeValue(attr));
+      XPath xpath = context.getAbdera().getXPath();
+      List<?> children = xpath.selectNodes("node()", element);
+      for (Object child : children) {
+        if (child instanceof Element) {
+          process(child, new ObjectContext(child), context, conventions);
+        } else if (child instanceof Comment) {
+          Comment comment = (Comment) child;
+          sw.writeComment(comment.getText());
+        } else if (child instanceof ProcessingInstruction) {
+          ProcessingInstruction pi = (ProcessingInstruction) child;
+          sw.writePI(pi.getText(), pi.getTarget());
+        } else if (child instanceof TextValue) {
+          TextValue tv = (TextValue) child;
+          sw.writeElementText(tv.getText());
+        }
+      }      
+      sw.endElement();
+  }
+  
+  
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FeedSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FeedSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FeedSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/FeedSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,41 @@
+/*
+* 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.ext.serializer.impl;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Entry;
+import org.apache.abdera.util.Constants;
+
+public class FeedSerializer 
+  extends SourceSerializer {
+
+  public FeedSerializer() {
+    super(Constants.FEED);
+  }
+  
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      super.process(source, objectContext, context, conventions);
+      writeElements(Entry.class, new EntrySerializer(), source, objectContext, context, conventions);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/GeneratorSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/GeneratorSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/GeneratorSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/GeneratorSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,88 @@
+/*
+* 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.ext.serializer.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Generator;
+import org.apache.abdera.ext.serializer.annotation.URI;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
+
+public class GeneratorSerializer 
+  extends ElementSerializer {
+
+  public GeneratorSerializer() {
+    super(Constants.GENERATOR);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      StreamWriter sw = context.getStreamWriter();
+      Generator _generator = objectContext.getAnnotation(Generator.class);
+
+      String uri = null;
+      AccessibleObject accessor = objectContext.getAccessor(URI.class, conventions);
+      if (accessor != null) {
+        Object value = eval(accessor, source);
+        if (value != null)
+          uri = toString(value);
+      }
+      if (uri == null) {
+        URI _uri = objectContext.getAnnotation(URI.class);
+        if (_uri != null && !_uri.value().equals(DEFAULT)) {
+          uri = _uri.value();
+        }
+      }
+      if (uri == null && _generator != null && !_generator.uri().equals(DEFAULT)) {
+        uri = _generator.uri();
+      }
+      if (uri != null)
+        sw.writeAttribute("uri", uri);
+      
+      String version = null;
+      accessor = objectContext.getAccessor(URI.class, conventions);
+      if (accessor != null) {
+        Object value = eval(accessor, source);
+        if (value != null)
+          version = toString(value);
+      }
+      if (version == null) {
+        URI _version = objectContext.getAnnotation(URI.class);
+        if (_version != null && !_version.value().equals(DEFAULT)) {
+          version = _version.value();
+        }
+      }
+      if (version == null && _generator != null && !_generator.version().equals(DEFAULT)) {
+        version = _generator.version();
+      }
+      if (version != null)
+        sw.writeAttribute("version", version);
+      
+      writeTextValue(source, objectContext, context, conventions);
+  }
+
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/IRISerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/IRISerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/IRISerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/IRISerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,65 @@
+/*
+* 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.ext.serializer.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.writer.StreamWriter;
+
+public class IRISerializer 
+  extends ElementSerializer {
+
+  public IRISerializer(
+    QName qname) {
+      super(qname);
+  }
+
+  public IRISerializer() {
+    super(null);
+  }
+  
+  protected void init(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      QName qname = this.qname != null ? this.qname : getQName(objectContext.getAccessor());
+      StreamWriter sw = context.getStreamWriter();
+      sw.startElement(qname);
+  }
+  
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(
+        source, 
+        objectContext, 
+        context, 
+        conventions);    
+      writeTextValue(
+        source, 
+        objectContext, 
+        context, 
+        conventions);
+  } 
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/LinkSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/LinkSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/LinkSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/LinkSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,136 @@
+/*
+* 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.ext.serializer.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.HrefLanguage;
+import org.apache.abdera.ext.serializer.annotation.Link;
+import org.apache.abdera.ext.serializer.annotation.MediaType;
+import org.apache.abdera.ext.serializer.annotation.Rel;
+import org.apache.abdera.ext.serializer.annotation.Title;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
+
+public class LinkSerializer 
+  extends ElementSerializer {
+
+  public LinkSerializer() {
+    super(Constants.LINK);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+    
+    StreamWriter sw = context.getStreamWriter();
+    Link _link = objectContext.getAnnotation(Link.class);
+    
+    String rel = null;
+    AccessibleObject accessor = objectContext.getAccessor(Rel.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        rel = toString(value);
+    }
+    if (rel == null) {
+      Rel _rel = objectContext.getAnnotation(Rel.class);
+      if (_rel != null && !_rel.value().equals(DEFAULT)) {
+        rel = _rel.value();
+      }
+    }
+    if (rel == null && _link != null && !_link.rel().equals(DEFAULT)) {
+      rel = _link.rel();
+    }
+    if (rel != null)
+      sw.writeAttribute("rel", rel);
+
+    String type = null;
+    accessor = objectContext.getAccessor(MediaType.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        type = toString(value);
+    }
+    if (type == null) {
+      MediaType _type = objectContext.getAnnotation(MediaType.class);
+      if (_type != null && !_type.value().equals(DEFAULT)) {
+        type = _type.value();
+      }
+    }
+    if (type == null && _link != null && !_link.type().equals(DEFAULT)) {
+      type = _link.type();
+    }
+    if (type != null)
+      sw.writeAttribute("type", type);
+    
+    
+    String title = null;
+    accessor = objectContext.getAccessor(Title.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        title = toString(value);
+    }
+    if (title == null && _link != null && !_link.title().equals(DEFAULT)) {
+      title = _link.title();
+    }
+    if (title != null)
+      sw.writeAttribute("title", title);
+
+    
+    String hreflang = null;
+    accessor = objectContext.getAccessor(HrefLanguage.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        hreflang = toString(value);
+    }
+    if (hreflang == null) {
+      HrefLanguage _hreflang = objectContext.getAnnotation(HrefLanguage.class);
+      if (_hreflang != null && !_hreflang.value().equals(DEFAULT)) {
+        hreflang = _hreflang.value();
+      }
+    }
+    if (hreflang == null && _link != null && !_link.hreflang().equals(DEFAULT)) {
+      hreflang = _link.hreflang();
+    }
+    if (hreflang != null)
+      sw.writeAttribute("hreflang", hreflang);
+    
+    String href = null;
+    accessor = objectContext.getAccessor(Value.class, conventions);
+    if (accessor != null) {
+      Object value = eval(accessor, source);
+      if (value != null)
+        href = toString(value);
+    }
+    if (href == null) href = toString(source);
+    if (href != null) 
+      sw.writeAttribute("href", href);
+    
+    writeAttributes(source, objectContext, context, conventions);
+    writeExtensions(source, objectContext, context, conventions);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/PersonSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/PersonSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/PersonSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/PersonSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,71 @@
+/*
+* 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.ext.serializer.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Email;
+import org.apache.abdera.ext.serializer.annotation.URI;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.util.Constants;
+import org.apache.abdera.writer.StreamWriter;
+
+public class PersonSerializer 
+  extends ElementSerializer {
+
+  public PersonSerializer(
+    QName qname) {
+      super(qname);
+  }
+
+  public PersonSerializer() {
+    super(null);
+  }
+  
+  protected void init(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+      QName qname = this.qname != null ? this.qname : getQName(objectContext.getAccessor());
+      StreamWriter sw = context.getStreamWriter();
+      sw.startElement(qname);
+  }
+  
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      if (!writeElement(Value.class, new SimpleElementSerializer(Constants.NAME), source, objectContext, context, conventions)) {
+        context.getStreamWriter()
+          .startElement(Constants.NAME)
+          .writeElementText(toString(source))
+          .endElement();
+      }
+      writeElement(Email.class, new SimpleElementSerializer(Constants.EMAIL), source, objectContext, context, conventions);
+      writeElement(URI.class, new SimpleElementSerializer(Constants.URI), source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+  }
+  
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ServiceSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ServiceSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ServiceSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/ServiceSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,44 @@
+/*
+* 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.ext.serializer.impl;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Workspace;
+import org.apache.abdera.util.Constants;
+
+public class ServiceSerializer 
+  extends ElementSerializer {
+
+  public ServiceSerializer() {
+    super(Constants.SERVICE);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+      writeElements(Workspace.class, new WorkspaceSerializer(), source, objectContext, context, conventions);
+  }
+
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SimpleElementSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SimpleElementSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SimpleElementSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SimpleElementSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,52 @@
+/*
+* 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.ext.serializer.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+
+public class SimpleElementSerializer 
+  extends ElementSerializer {
+
+  public SimpleElementSerializer(
+    QName qname) {
+      super(qname);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+    
+      writeAttributes(
+        source, 
+        objectContext, 
+        context, 
+        conventions);
+    
+      writeTextValue(
+        source, 
+        objectContext, 
+        context, 
+        conventions);
+  } 
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SourceSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SourceSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SourceSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/SourceSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,68 @@
+/*
+* 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.ext.serializer.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Author;
+import org.apache.abdera.ext.serializer.annotation.Category;
+import org.apache.abdera.ext.serializer.annotation.Contributor;
+import org.apache.abdera.ext.serializer.annotation.ID;
+import org.apache.abdera.ext.serializer.annotation.Icon;
+import org.apache.abdera.ext.serializer.annotation.Link;
+import org.apache.abdera.ext.serializer.annotation.Logo;
+import org.apache.abdera.ext.serializer.annotation.Rights;
+import org.apache.abdera.ext.serializer.annotation.Subtitle;
+import org.apache.abdera.ext.serializer.annotation.Title;
+import org.apache.abdera.ext.serializer.annotation.Updated;
+import org.apache.abdera.util.Constants;
+
+public class SourceSerializer 
+  extends ElementSerializer {
+
+  public SourceSerializer() {
+    super(Constants.SOURCE);
+  }
+  
+  protected SourceSerializer(QName qname) {
+    super(qname);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      writeElement (ID.class, new IRISerializer(Constants.ID), source, objectContext, context, conventions);
+      writeElement (Icon.class, new IRISerializer(Constants.ICON), source, objectContext, context, conventions);
+      writeElement (Logo.class, new IRISerializer(Constants.LOGO), source, objectContext, context, conventions);
+      writeElement (Title.class, new TextSerializer(Constants.TITLE), source, objectContext, context, conventions);
+      writeElement (Subtitle.class, new TextSerializer(Constants.SUBTITLE), source, objectContext, context, conventions);      
+      writeElement (Rights.class, new TextSerializer(Constants.RIGHTS), source, objectContext, context, conventions);
+      writeElement (Updated.class, new DateTimeSerializer(Constants.UPDATED), source, objectContext, context, conventions);
+      writeElements(Link.class, new LinkSerializer(), source, objectContext, context, conventions);
+      writeElements(Category.class, new CategorySerializer(), source, objectContext, context, conventions);
+      writeElements(Author.class, new PersonSerializer(Constants.AUTHOR), source, objectContext, context, conventions);
+      writeElements(Contributor.class, new PersonSerializer(Constants.CONTRIBUTOR), source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/TextSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/TextSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/TextSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/TextSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,104 @@
+/*
+* 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.ext.serializer.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Text;
+import org.apache.abdera.ext.serializer.annotation.Value;
+import org.apache.abdera.model.Div;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.Text.Type;
+import org.apache.abdera.writer.StreamWriter;
+
+public class TextSerializer 
+  extends ElementSerializer {
+
+  public TextSerializer(
+    QName qname) {
+      super(qname);
+  }
+
+  public TextSerializer() {
+    super(null);
+  }
+  
+  protected void init(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context,
+    Conventions conventions) {
+    
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+    
+    Type type = Type.TEXT;
+    Object contentValue = null;
+    ObjectContext valueContext = null;
+    AccessibleObject accessor = objectContext.getAccessor(Value.class, conventions);
+    if (accessor != null && !(source instanceof Element)) {
+      contentValue = eval(accessor, source);
+      valueContext = new ObjectContext(contentValue,source,accessor);
+      Text _text = valueContext.getAnnotation(Text.class);
+      type = _text != null ? _text.type() : type;
+    } else {
+      Text _text = objectContext.getAnnotation(Text.class);
+      type = _text != null ? _text.type() : type;
+      contentValue = source;
+      valueContext = objectContext;
+    }
+    QName qname = this.qname != null ? this.qname : getQName(objectContext.getAccessor());
+    StreamWriter sw = context.getStreamWriter();
+    sw.startText(qname,type);
+    writeAttributes(
+        source, 
+        objectContext, 
+        context, 
+        conventions);
+
+    switch(type) {
+      case TEXT:
+      case HTML:
+        sw.writeElementText(toString(contentValue));
+        break;
+      case XHTML:
+        Div div = null;
+        if (contentValue instanceof Div)
+          div = (Div) contentValue;
+        else {
+          div = context.getAbdera().getFactory().newDiv();
+          div.setValue(toString(contentValue));
+        } 
+        context.serialize(div, new ObjectContext(div));
+        break;
+    }
+  }
+    
+  
+  
+}

Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/WorkspaceSerializer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/WorkspaceSerializer.java?rev=616050&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/WorkspaceSerializer.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/ext/serializer/impl/WorkspaceSerializer.java Mon Jan 28 13:26:00 2008
@@ -0,0 +1,43 @@
+/*
+* 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.ext.serializer.impl;
+
+import org.apache.abdera.ext.serializer.Conventions;
+import org.apache.abdera.ext.serializer.ObjectContext;
+import org.apache.abdera.ext.serializer.SerializationContext;
+import org.apache.abdera.ext.serializer.annotation.Collection;
+import org.apache.abdera.util.Constants;
+
+public class WorkspaceSerializer 
+  extends ElementSerializer {
+
+  public WorkspaceSerializer() {
+    super(Constants.WORKSPACE);
+  }
+
+  protected void process(
+    Object source, 
+    ObjectContext objectContext,
+    SerializationContext context, 
+    Conventions conventions) {
+      writeAttributes(source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+      writeElements(Collection.class, new CollectionSerializer(), source, objectContext, context, conventions);
+      writeExtensions(source, objectContext, context, conventions);
+  }
+}