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 2007/08/21 02:51:29 UTC

svn commit: r567888 [3/4] - in /incubator/abdera/java/trunk: ./ build/ extensions/ extensions/gdata/ extensions/gdata/src/ extensions/gdata/src/main/ extensions/gdata/src/main/java/ extensions/gdata/src/main/java/org/ extensions/gdata/src/main/java/org...

Added: incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/InReplyTo.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,106 @@
+/*
+* 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.thread;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class InReplyTo 
+  extends ElementWrapper {
+
+  public InReplyTo(Element internal) {
+    super(internal);
+  }
+
+  public InReplyTo(Factory factory) {
+    super(factory, ThreadConstants.IN_REPLY_TO);
+  }
+
+  public IRI getHref() {
+    String href = getAttributeValue("href");
+    return (href != null) ? new IRI(href) : null;
+  }
+
+  public MimeType getMimeType() {
+    try {
+      String type = getAttributeValue("type");
+      return (type != null) ? new MimeType(type) : null;
+    } catch (javax.activation.MimeTypeParseException e) {
+      throw new org.apache.abdera.util.MimeTypeParseException(e);
+    }
+  }
+
+  public IRI getRef() {
+    String ref = getAttributeValue("ref");
+    return (ref != null) ? new IRI(ref) : null;
+  }
+
+  public IRI getResolvedHref() {
+    IRI href = getHref();
+    IRI base = getBaseUri();
+    return (base == null) ? href : (href != null) ? base.resolve(href) : null; 
+  }
+
+  public IRI getResolvedSource() {
+    IRI href = getSource();
+    IRI base = getBaseUri();
+    return (base == null) ? href : (href != null) ? base.resolve(href) : null;
+  }
+
+  public IRI getSource() {
+    String source = getAttributeValue("source");
+    return (source != null) ? new IRI(source) : null;
+  }
+
+  public void setHref(IRI ref) {
+    setAttributeValue("href", ref.toString());
+  }
+
+  public void setHref(String ref) {
+    setAttributeValue("href", ref);
+  }
+
+  public void setMimeType(MimeType mimeType) {
+    setAttributeValue("type", mimeType.toString());
+  }
+
+  public void setMimeType(String mimeType) {
+    setAttributeValue("type", mimeType);
+  }
+
+  public void setRef(IRI ref) {
+    setAttributeValue("ref", ref.toString());
+  }
+
+  public void setRef(String ref) {
+    setAttributeValue("ref", ref);
+  }
+
+  public void setSource(IRI source) {
+    setAttributeValue("source", source.toString());
+  }
+
+  public void setSource(String source) {
+    setAttributeValue("source", source);
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadConstants.java Mon Aug 20 17:51:20 2007
@@ -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.thread;
+
+import javax.xml.namespace.QName;
+import org.apache.abdera.util.Constants;
+
+public interface ThreadConstants extends Constants {
+
+  public static final String THR_NS = "http://purl.org/syndication/thread/1.0";
+  public static final String LN_INREPLYTO = "in-reply-to";
+  public static final String LN_REF = "ref";
+  public static final String LN_COUNT = "count";
+  public static final String LN_WHEN = "when";
+  public static final String LN_TOTAL = "total";
+  public static final String THR_PREFIX = "thr";
+  public static final QName IN_REPLY_TO = new QName(THR_NS, LN_INREPLYTO, THR_PREFIX);
+  public static final QName THRCOUNT = new QName(THR_NS, LN_COUNT, THR_PREFIX);
+  /** @deprecated Use Constants.THRUPDATED */
+  public static final QName THRWHEN = new QName(THR_NS, LN_WHEN, THR_PREFIX);
+  public static final QName THRUPDATED = new QName(THR_NS, LN_UPDATED, THR_PREFIX);
+  public static final QName THRTOTAL = new QName(THR_NS, LN_TOTAL, THR_PREFIX);
+  public static final QName THRREF = new QName(LN_REF);
+  public static final QName THRSOURCE = new QName(LN_SOURCE);
+
+  
+}

Added: incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadExtensionFactory.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,32 @@
+/*
+* 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.thread;
+
+import org.apache.abdera.util.AbstractExtensionFactory;
+
+public final class ThreadExtensionFactory 
+  extends AbstractExtensionFactory
+  implements ThreadConstants {
+
+  public ThreadExtensionFactory() {
+    super(ThreadConstants.THR_NS);
+    addImpl(IN_REPLY_TO,InReplyTo.class);
+    addImpl(THRTOTAL,Total.class);
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/ThreadHelper.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,194 @@
+/*
+* 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.thread;
+
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.AtomDate;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Link;
+import org.apache.abdera.model.Source;
+import org.apache.abdera.i18n.iri.IRI;
+
+public final class ThreadHelper {
+
+  ThreadHelper() {}
+  
+  public static int getCount(Link link) {
+    String val = link.getAttributeValue(ThreadConstants.THRCOUNT);
+    return (val != null) ? Integer.parseInt(val) : 0;
+  }
+  
+  @SuppressWarnings("deprecation")
+  public static AtomDate getUpdated(Link link) {
+    String val = link.getAttributeValue(ThreadConstants.THRUPDATED);
+    if (val == null) // thr:when was updated to thr:updated, some old impls may still be using thr:when
+      val = link.getAttributeValue(ThreadConstants.THRWHEN);
+    return (val != null) ? AtomDate.valueOf(val) : null;
+  }
+  
+  public static void setCount(
+    Link link, 
+    int count) {
+      link.setAttributeValue(
+        ThreadConstants.THRCOUNT, 
+        String.valueOf(count).trim());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    Date when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    Calendar when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    long when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  public static void setUpdated(
+    Link link, 
+    String when) {
+      link.setAttributeValue(
+        ThreadConstants.THRUPDATED, 
+        AtomDate.valueOf(when).getValue());
+  }
+  
+  
+  public static Total addTotal(Entry entry, int total) {
+    Factory factory = entry.getFactory();
+    Total totalelement = 
+      (Total)factory.newExtensionElement(
+        ThreadConstants.THRTOTAL, entry);
+    totalelement.setValue(total);
+    return totalelement;
+  }
+  
+  public static Total getTotal(Entry entry) {
+    return entry.getFirstChild(ThreadConstants.THRTOTAL);
+  }
+  
+  public static void addInReplyTo(Entry entry, InReplyTo replyTo) {
+    entry.addExtension(replyTo);
+  }
+  
+  public static InReplyTo addInReplyTo(Entry entry) {
+    return entry.addExtension(ThreadConstants.IN_REPLY_TO);
+  }
+
+  public static InReplyTo addInReplyTo(Entry entry, Entry ref) {
+    if (ref.equals(entry)) return null;
+    InReplyTo irt = addInReplyTo(entry); 
+    try {
+      irt.setRef(ref.getId());
+      Link altlink = ref.getAlternateLink();
+      if (altlink != null) {
+        irt.setHref(altlink.getResolvedHref());
+        if (altlink.getMimeType() != null) 
+          irt.setMimeType(altlink.getMimeType());
+      }
+      Source src = ref.getSource();
+      if (src != null) {
+        Link selflink = src.getSelfLink();
+        if (selflink != null)
+          irt.setSource(selflink.getResolvedHref());
+      }
+    } catch (Exception e) {}
+    return irt;
+  }
+
+  public static InReplyTo addInReplyTo(Entry entry, IRI ref) {
+    try {
+      if (entry.getId() != null && entry.getId().equals(ref)) return null;
+    } catch (Exception e) {}
+    InReplyTo irt = addInReplyTo(entry);
+    irt.setRef(ref);
+    return irt;
+  }
+
+  public static InReplyTo addInReplyTo(Entry entry, String ref) {
+    return addInReplyTo(entry, new IRI(ref));
+  }
+
+  public static InReplyTo addInReplyTo(
+    Entry entry,
+    IRI ref, 
+    IRI source, 
+    IRI href, 
+    MimeType type) {
+      InReplyTo irt = addInReplyTo(entry, ref);
+      if (irt != null) {
+        if (source != null) irt.setSource(source);
+        if (href != null) irt.setHref(href);
+        if (type != null) irt.setMimeType(type);
+      }
+      return irt;
+  }
+
+  public static InReplyTo addInReplyTo(
+    Entry entry,
+    String ref, 
+    String source, 
+    String href, 
+    String type) {
+    InReplyTo irt = addInReplyTo(entry, ref);
+    if (irt != null) {
+      if (source != null) irt.setSource(source);
+      if (href != null) irt.setHref(href);
+      if (type != null) irt.setMimeType(type);
+    }
+    return irt;
+  }
+
+  public static InReplyTo getInReplyTo(Entry entry) {
+    return entry.getFirstChild(ThreadConstants.IN_REPLY_TO);
+  }
+
+  @SuppressWarnings("unchecked")
+  public static List<InReplyTo> getInReplyTos(Entry entry) {
+    List list = entry.getExtensions(ThreadConstants.IN_REPLY_TO);
+    return list;
+  }
+
+  public static InReplyTo newInReplyTo(Factory factory) {
+    return new InReplyTo(factory);
+  }
+  
+  public static Total newTotal(Factory factory) {
+    return new Total(factory);
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/Total.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/Total.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/Total.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/main/java/org/apache/abdera/ext/thread/Total.java Mon Aug 20 17:51:20 2007
@@ -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.thread;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class Total 
+  extends ElementWrapper {
+
+  public Total(Element internal) {
+    super(internal);
+  }
+
+  public Total(Factory factory) {
+    super(factory, ThreadConstants.THRTOTAL);
+  }
+
+  public int getValue() {
+    String val = getText();
+    return (val != null) ? Integer.parseInt(val) : -1;
+  }
+
+  public void setValue(int value) {
+    setText(String.valueOf(value));
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/main/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory (added)
+++ incubator/abdera/java/trunk/extensions/main/src/main/resources/META-INF/services/org.apache.abdera.factory.ExtensionFactory Mon Aug 20 17:51:20 2007
@@ -0,0 +1,2 @@
+org.apache.abdera.ext.thread.ThreadExtensionFactory
+org.apache.abdera.ext.features.FeaturesExtensionFactory

Added: incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/bidi/BidiTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/bidi/BidiTest.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/bidi/BidiTest.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/bidi/BidiTest.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,47 @@
+/*
+* 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.test.ext.bidi;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.bidi.BidiHelper;
+import org.apache.abdera.ext.bidi.BidiHelper.Direction;
+import org.apache.abdera.model.Feed;
+
+import junit.framework.TestCase;
+
+public class BidiTest extends TestCase {
+
+  public static void testBidi() throws Exception {
+    
+    Abdera abdera = new Abdera();
+    Feed feed = abdera.getFactory().newFeed();
+    feed.setTitle("Testing");
+    feed.setSubtitle("Testing");
+    BidiHelper.setDirection(Direction.RTL, feed);
+    BidiHelper.setDirection(Direction.LTR, feed.getSubtitleElement());
+    
+    assertNotNull(feed.getAttributeValue("dir"));
+    assertEquals(BidiHelper.getDirection(feed), Direction.RTL);
+    assertEquals(BidiHelper.getDirection(feed.getTitleElement()), Direction.RTL);
+    assertEquals(BidiHelper.getDirection(feed.getSubtitleElement()), Direction.LTR);
+    assertEquals(BidiHelper.getBidiElementText(feed.getTitleElement()), BidiHelper.getBidiText(Direction.RTL, "Testing"));
+    assertEquals(BidiHelper.getBidiElementText(feed.getSubtitleElement()), BidiHelper.getBidiText(Direction.LTR, "Testing"));
+    
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/features/FeatureTest.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,103 @@
+/*
+* 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.test.ext.features;
+
+import junit.framework.TestCase;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.features.AcceptSelector;
+import org.apache.abdera.ext.features.Feature;
+import org.apache.abdera.ext.features.FeatureSelector;
+import org.apache.abdera.ext.features.FeaturesHelper;
+import org.apache.abdera.ext.features.Selector;
+import org.apache.abdera.ext.features.XPathSelector;
+import org.apache.abdera.ext.features.Feature.Status;
+import org.apache.abdera.model.Collection;
+import org.apache.abdera.model.Service;
+import org.apache.abdera.model.Workspace;
+
+public class FeatureTest extends TestCase {
+
+  public static void testFeatures() throws Exception {
+    Abdera abdera = new Abdera();
+    Collection coll = abdera.getFactory().newCollection();
+    FeaturesHelper.addFeature(
+      coll, "http://example.com/features/foo", 
+      Status.REQUIRED, null, "foo & here");
+    FeaturesHelper.addFeature(
+      coll, "http://example.com/features/bar", 
+      null, null, null);
+    FeaturesHelper.addFeature(
+      coll, "http://example.com/features/baz",
+      Status.UNSUPPORTED);
+    
+    assertEquals(Status.REQUIRED,FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/foo"));
+    assertEquals(Status.SUPPORTED, FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/bar"));
+    assertEquals(Status.UNSUPPORTED, FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/baz"));
+    assertEquals(Status.UNSPECIFIED,FeaturesHelper.getFeatureStatus(
+      coll, "http://example.com/features/pez"));
+
+  }
+  
+  public static void testSelectors() throws Exception {
+    
+    Abdera abdera = new Abdera();
+    Service service = abdera.newService();
+    Workspace workspace = service.addWorkspace("a");
+    Collection collection1 = workspace.addCollection("a1","a1");
+    collection1.setAcceptsEntry();
+    FeaturesHelper.addFeature(collection1, FeaturesHelper.FEATURE_DRAFTS);
+    Collection collection2 = workspace.addCollection("a2","a2");
+    collection2.setAccept("image/*");
+    
+    Selector s1 = new FeatureSelector(FeaturesHelper.FEATURE_DRAFTS);
+    
+    Collection[] collections = FeaturesHelper.select(service, s1);
+    
+    assertEquals(1,collections.length);
+    assertEquals(collections[0],collection1);
+    
+    Selector s2 = new AcceptSelector("image/png");
+    
+    collections = FeaturesHelper.select(service,s2);
+    
+    assertEquals(1,collections.length);
+    assertEquals(collections[0],collection2);
+    
+    Selector s3 = new XPathSelector(
+      "f:feature[@ref='http://www.w3.org/2007/app/drafts']");
+    
+    collections = FeaturesHelper.select(service,s3);
+    
+    assertEquals(1,collections.length);
+    assertEquals(collections[0],collection1);
+  }
+  
+
+  public static void testType() throws Exception {
+     Abdera abdera = new Abdera();
+     Feature feature = abdera.getFactory().newElement(FeaturesHelper.FEATURE);
+     FeaturesHelper.addType(feature, "image/jpg","image/gif","image/png","image/*");
+     String[] types = FeaturesHelper.getTypes(feature);
+     assertEquals(1,types.length);
+     assertEquals("image/*", types[0]);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/history/FeedPagingTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/history/FeedPagingTest.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/history/FeedPagingTest.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/history/FeedPagingTest.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,82 @@
+/*
+* 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.test.ext.history;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.history.FeedPagingHelper;
+import org.apache.abdera.model.Feed;
+
+import junit.framework.TestCase;
+
+public class FeedPagingTest extends TestCase {
+
+  public static void testHistory() throws Exception {
+    
+    Abdera abdera = new Abdera();
+    
+    Feed feed = abdera.newFeed();
+
+    FeedPagingHelper.setComplete(feed, true);
+    FeedPagingHelper.setArchive(feed, true);
+
+    FeedPagingHelper.setNext(feed, "http://example.org/foo");
+    FeedPagingHelper.setNext(feed, "http://example.org/bar");
+    
+    FeedPagingHelper.setPrevious(feed, "http://example.org/foo");
+    FeedPagingHelper.setPrevious(feed, "http://example.org/bar");
+    
+    FeedPagingHelper.setLast(feed, "http://example.org/foo");
+    FeedPagingHelper.setLast(feed, "http://example.org/bar");
+
+    FeedPagingHelper.setFirst(feed, "http://example.org/foo");
+    FeedPagingHelper.setFirst(feed, "http://example.org/bar");
+
+    FeedPagingHelper.setPreviousArchive(feed, "http://example.org/foo");
+    FeedPagingHelper.setPreviousArchive(feed, "http://example.org/bar");
+    
+    FeedPagingHelper.setNextArchive(feed, "http://example.org/foo");
+    FeedPagingHelper.setNextArchive(feed, "http://example.org/bar");
+
+    FeedPagingHelper.setCurrent(feed, "http://example.org/foo");
+    FeedPagingHelper.setCurrent(feed, "http://example.org/bar");
+    
+    assertTrue(FeedPagingHelper.isPaged(feed));
+    assertTrue(FeedPagingHelper.isComplete(feed));
+    assertTrue(FeedPagingHelper.isArchive(feed));
+    
+    assertNotNull(FeedPagingHelper.getNext(feed));
+    assertNotNull(FeedPagingHelper.getPrevious(feed));
+    assertNotNull(FeedPagingHelper.getLast(feed));
+    assertNotNull(FeedPagingHelper.getFirst(feed));
+    assertNotNull(FeedPagingHelper.getNextArchive(feed));
+    assertNotNull(FeedPagingHelper.getPreviousArchive(feed));
+    assertNotNull(FeedPagingHelper.getCurrent(feed));
+    
+    assertEquals(FeedPagingHelper.getNext(feed).toString(),"http://example.org/bar");
+  }
+  
+  public static void testHistory2() throws Exception {
+    Abdera abdera = new Abdera();
+    Feed feed = abdera.newFeed();
+    QName complete = new QName(FeedPagingHelper.FHNS, "complete","x");
+    feed.addExtension(complete);
+    assertTrue(FeedPagingHelper.isComplete(feed));
+  }
+}

Added: incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/license/LicenseTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/license/LicenseTest.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/license/LicenseTest.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/license/LicenseTest.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,99 @@
+/*
+* 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.test.ext.license;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.license.LicenseHelper;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.Feed;
+
+import junit.framework.TestCase;
+
+public class LicenseTest extends TestCase {
+
+  public static void testLicense() throws Exception {
+    
+    String license = "http://example.org";
+    
+    Abdera abdera = new Abdera();
+    Feed feed = abdera.newFeed();
+    
+    Entry entry = feed.addEntry();
+    
+    LicenseHelper.addLicense(feed, license);
+    
+    assertTrue(LicenseHelper.hasLicense(feed, license));
+    assertFalse(LicenseHelper.hasLicense(entry, license, false));
+    assertTrue(LicenseHelper.hasLicense(entry, license, true));
+    
+    assertNotNull(LicenseHelper.addUnspecifiedLicense(entry));
+
+    assertFalse(LicenseHelper.hasLicense(entry, license, true));
+    
+    entry = abdera.newEntry();
+    entry.setSource(feed.getAsSource());
+    
+    assertFalse(LicenseHelper.hasLicense(entry, license, false));
+    assertTrue(LicenseHelper.hasLicense(entry, license, true));
+    
+    boolean died = false;
+    entry = abdera.newEntry();
+    LicenseHelper.addLicense(entry, license);
+    try {
+      // will die because the license already exists
+      LicenseHelper.addLicense(entry, license);
+    } catch(IllegalStateException e) {
+      died = true;
+    }
+    assertTrue(died);
+    
+    died = false;
+    try {
+      // will die because another license already exists
+      LicenseHelper.addUnspecifiedLicense(entry);
+    } catch(IllegalStateException e) {
+      died = true;
+    }
+    assertTrue(died);
+    
+    died = false;
+    entry = abdera.newEntry();
+    LicenseHelper.addUnspecifiedLicense(entry);
+    try {
+      // will die because the unspecified license already exists
+      LicenseHelper.addLicense(entry, license);
+    } catch (IllegalStateException e) {
+      died = true;
+    }
+    assertTrue(died);
+    
+    died = false;
+    entry = abdera.newEntry();
+    LicenseHelper.addUnspecifiedLicense(entry);
+    try {
+      // will die because the unspecified license already exists
+      LicenseHelper.addUnspecifiedLicense(entry);
+    } catch (IllegalStateException e) {
+      died = true;
+    }
+    assertTrue(died);
+    
+    
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/main/TestSuite.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,40 @@
+/*
+* 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.test.ext.main;
+
+import org.apache.abdera.test.ext.bidi.BidiTest;
+import org.apache.abdera.test.ext.features.FeatureTest;
+import org.apache.abdera.test.ext.history.FeedPagingTest;
+import org.apache.abdera.test.ext.license.LicenseTest;
+import org.apache.abdera.test.ext.thread.ThreadTest;
+
+public class TestSuite extends junit.framework.TestSuite {
+  public static void main(String[] args)
+  {
+    junit.textui.TestRunner.run(new TestSuite());
+  }
+
+  public TestSuite()
+  {
+    addTestSuite(FeedPagingTest.class);
+    addTestSuite(ThreadTest.class);
+    addTestSuite(BidiTest.class);
+    addTestSuite(FeatureTest.class);
+    addTestSuite(LicenseTest.class);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/thread/ThreadTest.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/thread/ThreadTest.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/thread/ThreadTest.java (added)
+++ incubator/abdera/java/trunk/extensions/main/src/test/java/org/apache/abdera/test/ext/thread/ThreadTest.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,48 @@
+/*
+* 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.test.ext.thread;
+
+import org.apache.abdera.Abdera;
+import org.apache.abdera.ext.thread.InReplyTo;
+import org.apache.abdera.ext.thread.ThreadConstants;
+import org.apache.abdera.ext.thread.ThreadHelper;
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Entry;
+
+import junit.framework.TestCase;
+
+public class ThreadTest extends TestCase {
+
+  public static void testThread() throws Exception {
+    
+    Abdera abdera = new Abdera();
+    Factory factory = abdera.getFactory();
+    Entry e1 = factory.newEntry();
+    Entry e2 = factory.newEntry();
+    
+    e1.setId("tag:example.org,2006:first");
+    e2.setId("tag:example.org,2006:second");
+    
+    ThreadHelper.addInReplyTo(e2,e1); // e2 is a response to e1
+    assertNotNull(e2.getExtension(ThreadConstants.IN_REPLY_TO));
+    InReplyTo irt = e2.getExtension(ThreadConstants.IN_REPLY_TO);
+    assertEquals(irt.getRef(), e1.getId());
+    
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/media/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/pom.xml?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/pom.xml (added)
+++ incubator/abdera/java/trunk/extensions/media/pom.xml Mon Aug 20 17:51:20 2007
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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. -->
+<project 
+  xmlns="http://maven.apache.org/POM/4.0.0" 
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <parent>
+    <groupId>org.apache.abdera</groupId>
+    <artifactId>abdera</artifactId>
+    <version>0.3.0-incubating-SNAPSHOT</version>
+  </parent>  
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>abdera-extensions-media</artifactId>
+  <packaging>jar</packaging>
+  <name>Abdera Extensions - Media</name>
+  <version>0.3.0-incubating-SNAPSHOT</version>
+  <description>Atom Specification Extensions - Media</description>
+  <inceptionYear>2006</inceptionYear>
+  <url>http://incubator.apache.org/abdera</url>
+  <scm>
+    <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/abdera/java/trunk/extensions/media</connection>
+    <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/abdera/java/trunk/extensions/media</developerConnection>
+    <url>http://svn.apache.org/repos/asf/incubator/abdera/java/trunk/extensions/media</url>
+  </scm>
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-core</artifactId>
+      <version>0.3.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>    
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-parser</artifactId>
+      <version>0.3.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>   
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-protocol</artifactId>
+      <version>0.3.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>  
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>abdera-client</artifactId>
+      <version>0.3.0-incubating-SNAPSHOT</version>
+      <scope>compile</scope>
+    </dependency>  
+    <dependency>
+      <groupId>org.apache.abdera</groupId>
+      <artifactId>json</artifactId>
+      <version>1.0</version>
+      <scope>compile</scope>
+    </dependency>   
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.ws.commons.axiom</groupId>
+      <artifactId>axiom-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>stax</groupId>
+      <artifactId>stax-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.woodstox</groupId>
+      <artifactId>wstx-asl</artifactId>
+    </dependency> 
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+  </dependencies>
+</project>

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaAdult.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaAdult.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaAdult.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaAdult.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,37 @@
+/*
+* 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.media;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+/**
+ * @deprecated Use MediaRating instead
+ */
+public class MediaAdult extends ElementWrapper {
+
+  protected MediaAdult(Element internal) {
+    super(internal);
+  }
+
+  public MediaAdult(Factory factory) {
+    super(factory, MediaConstants.ADULT);
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCategory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCategory.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCategory.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCategory.java Mon Aug 20 17:51:20 2007
@@ -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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class MediaCategory extends ElementWrapper {
+
+  public MediaCategory(Element internal) {
+    super(internal);
+  }
+
+  public MediaCategory(Factory factory) {
+    super(factory, MediaConstants.CATEGORY);
+  }
+
+  public IRI getScheme() {
+    String scheme = getAttributeValue("scheme");
+    return (scheme != null) ? new IRI(scheme) : null;
+  }
+  
+  public void setScheme(String scheme) {
+    if (scheme != null)
+      setAttributeValue("scheme",(new IRI(scheme)).toString());
+    else 
+      removeAttribute(new QName("scheme"));
+  }
+  
+  public String getLabel() {
+    return getAttributeValue("label");
+  }
+  
+  public void setLabel(String label) {
+    if (label != null)
+      setAttributeValue("label", label);
+    else 
+      removeAttribute(new QName("label"));
+  }
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaConstants.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaConstants.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaConstants.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaConstants.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,66 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+public interface MediaConstants {
+
+  public enum Type { PLAIN, HTML }
+  public enum Algo { SHA1, MD5 }
+  public enum Relationship { ALLOW, DENY }
+  public enum RestrictionType { COUNTRY, URI }
+  public enum Medium { IMAGE, AUDIO, VIDEO, DOCUMENT, EXECUTABLE }
+  public enum Expression { FULL, SAMPLE, NONSTOP }
+  
+  public static final String MEDIA_NS = "http://search.yahoo.com/mrss/";
+  public static final String MEDIA_PREFIX = "media";
+  public static final String LN_GROUP = "group";
+  public static final String LN_CONTENT = "content";
+  public static final String LN_ADULT = "adult";
+  public static final String LN_RATING = "rating";
+  public static final String LN_TITLE = "title";
+  public static final String LN_DESCRIPTION = "description";
+  public static final String LN_KEYWORDS = "keywords";
+  public static final String LN_THUMBNAIL = "thumbnail";
+  public static final String LN_CATEGORY = "category";
+  public static final String LN_HASH = "hash";
+  public static final String LN_PLAYER = "player";
+  public static final String LN_CREDIT = "credit";
+  public static final String LN_COPYRIGHT = "copyright";
+  public static final String LN_TEXT = "text";
+  public static final String LN_RESTRICTION = "restriction";
+  
+  public static final QName GROUP = new QName(MEDIA_NS, LN_GROUP, MEDIA_PREFIX);
+  public static final QName CONTENT = new QName(MEDIA_NS, LN_CONTENT, MEDIA_PREFIX);
+  public static final QName ADULT = new QName(MEDIA_NS, LN_ADULT, MEDIA_PREFIX);
+  public static final QName RATING = new QName(MEDIA_NS, LN_RATING, MEDIA_PREFIX);
+  public static final QName TITLE = new QName(MEDIA_NS, LN_TITLE, MEDIA_PREFIX);
+  public static final QName DESCRIPTION = new QName(MEDIA_NS, LN_DESCRIPTION, MEDIA_PREFIX);
+  public static final QName KEYWORDS = new QName(MEDIA_NS, LN_KEYWORDS, MEDIA_PREFIX);
+  public static final QName THUMBNAIL = new QName(MEDIA_NS, LN_THUMBNAIL, MEDIA_PREFIX);
+  public static final QName CATEGORY = new QName(MEDIA_NS, LN_CATEGORY, MEDIA_PREFIX);
+  public static final QName HASH = new QName(MEDIA_NS, LN_HASH, MEDIA_PREFIX);
+  public static final QName PLAYER = new QName(MEDIA_NS, LN_PLAYER, MEDIA_PREFIX);
+  public static final QName CREDIT = new QName(MEDIA_NS, LN_CREDIT, MEDIA_PREFIX);
+  public static final QName COPYRIGHT = new QName(MEDIA_NS, LN_COPYRIGHT, MEDIA_PREFIX);
+  public static final QName TEXT = new QName(MEDIA_NS, LN_TEXT, MEDIA_PREFIX);
+  public static final QName RESTRICTION = new QName(MEDIA_NS, LN_RESTRICTION, MEDIA_PREFIX);
+  
+}
+

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaContent.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaContent.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaContent.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaContent.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,205 @@
+/*
+* 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.media;
+
+import javax.activation.MimeType;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class MediaContent 
+  extends ExtensibleElementWrapper {
+
+  public MediaContent(Element internal) {
+    super(internal);
+  }
+
+  public MediaContent(Factory factory) {
+    super(factory, MediaConstants.CONTENT);
+  }
+  
+  public IRI getUrl() {
+    String url = getAttributeValue("url");
+    return (url != null) ? new IRI(url) : null;
+  }
+  
+  public void setUrl(String url) {
+    if (url != null)
+      setAttributeValue("url", (new IRI(url)).toString());
+    else
+      removeAttribute(new QName("url"));
+  }
+  
+  public long getFilesize() {
+    String size = getAttributeValue("filesize");
+    return (size != null) ? Long.parseLong(size) : -1;
+  }
+  
+  public void setFilesize(long size) {
+    if (size > -1) 
+      setAttributeValue("filesize", String.valueOf(size));
+    else 
+      removeAttribute(new QName("filesize"));
+  }
+  
+  public MimeType getType() {
+    try {
+      String type = getAttributeValue("type");
+      return (type != null) ? new MimeType(type) : null;
+    } catch (javax.activation.MimeTypeParseException e) {
+      throw new org.apache.abdera.util.MimeTypeParseException(e);
+    }
+  }
+  
+  public void setType(String type) {
+    if (type != null)
+      setAttributeValue("type", type);
+    else 
+      removeAttribute(new QName(type));
+  }
+  
+  public MediaConstants.Medium getMedium() {
+    String medium = getAttributeValue("medium");
+    return (medium != null) ? MediaConstants.Medium.valueOf(medium.toUpperCase()) : null;
+  }
+  
+  public void setMedium(MediaConstants.Medium medium) {
+    if (medium != null) 
+      setAttributeValue("medium", medium.name().toLowerCase());
+    else 
+      removeAttribute(new QName("medium"));
+  }
+  
+  public boolean isDefault() {
+    String def = getAttributeValue("isDefault");
+    return (def != null) ? def.equalsIgnoreCase("true") : false;
+  }
+  
+  public MediaConstants.Expression getExpression() {
+    String exp = getAttributeValue("expression");
+    return (exp != null) ? MediaConstants.Expression.valueOf(exp.toUpperCase()) : null;
+  }
+  
+  public void setExpression(MediaConstants.Expression exp) {
+    if (exp != null) 
+      setAttributeValue("expression", exp.name().toLowerCase());
+    else 
+      removeAttribute(new QName("expression"));
+  }
+  
+  public int getBitrate() {
+    String bitrate = getAttributeValue("bitrate");
+    return (bitrate != null) ? Integer.parseInt(bitrate) : -1;
+  }
+  
+  public void setBitrate(int bitrate) {
+    if (bitrate > -1)
+      setAttributeValue("bitrate", String.valueOf(bitrate));
+    else
+      removeAttribute(new QName("bitrate"));
+  }
+  
+  public int getFramerate() {
+    String framerate = getAttributeValue("framerate");
+    return (framerate != null) ? Integer.parseInt(framerate) : -1;
+  }
+  
+  public void setFramerate(int framerate) {
+    if (framerate > -1)
+      setAttributeValue("framerate", String.valueOf(framerate));
+    else
+      removeAttribute(new QName("framerate"));
+  }
+  
+  public double getSamplingRate() {
+    String rate = getAttributeValue("samplingrate");
+    return (rate != null) ? Double.parseDouble(rate) : -1;
+  }
+  
+  public void setSamplingRate(double samplingrate) {
+    if (samplingrate > Double.parseDouble("-1"))
+      setAttributeValue("samplingrate", String.valueOf(samplingrate));
+    else 
+      removeAttribute(new QName("samplingrate"));
+  }
+  
+  public int getChannels() {
+    String c = getAttributeValue("channels");
+    return (c != null) ? Integer.parseInt(c) : -1;
+  }
+  
+  public void setChannels(int channels) {
+    if (channels > -1) 
+      setAttributeValue("channels", String.valueOf(channels));
+    else
+      removeAttribute(new QName("channels"));
+  }
+  
+  public int getDuration() {
+    String c = getAttributeValue("duration");
+    return (c != null) ? Integer.parseInt(c) : -1;
+  }
+  
+  public void setDuration(int duration) {
+    if (duration > -1) 
+      setAttributeValue("duration", String.valueOf(duration));
+    else
+      removeAttribute(new QName("duration"));
+  }
+  
+  public int getWidth() {
+    String width = getAttributeValue("width");
+    return (width != null) ? Integer.parseInt(width) : -1;
+  }
+  
+  public void setWidth(int width) {
+    if (width > -1) {
+      setAttributeValue("width", String.valueOf(width));
+    } else {
+      removeAttribute(new QName("width"));
+    }
+  }
+  
+  public int getHeight() {
+    String height = getAttributeValue("height");
+    return (height != null) ? Integer.parseInt(height) : -1;
+  }
+  
+  public void setHeight(int height) {
+    if (height > -1) {
+      setAttributeValue("height", String.valueOf(height));
+    } else {
+      removeAttribute(new QName("height"));
+    }
+  }
+
+  public String getLang() {
+    return getAttributeValue("lang");
+  }
+  
+  public void setLang(String lang) {
+    if (lang != null)
+      setAttributeValue("lang", lang);
+    else
+      removeAttribute(new QName("lang"));
+  }
+
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCopyright.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCopyright.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCopyright.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCopyright.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,48 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class MediaCopyright extends ElementWrapper {
+
+  public MediaCopyright(Element internal) {
+    super(internal);
+  }
+
+  public MediaCopyright(Factory factory) {
+    super(factory, MediaConstants.COPYRIGHT);
+  }
+  
+  public IRI getUrl() {
+    String url = getAttributeValue("url");
+    return (url != null) ? new IRI(url) : null;
+  }
+  
+  public void setUrl(String url) {
+    if (url != null)
+      setAttributeValue("url", (new IRI(url)).toString());
+    else
+      removeAttribute(new QName("url"));
+  }
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCredit.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCredit.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCredit.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaCredit.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,60 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class MediaCredit extends ElementWrapper {
+
+  public MediaCredit(Element internal) {
+    super(internal);
+  }
+
+  public MediaCredit(Factory factory) {
+    super(factory, MediaConstants.CREDIT);
+  }
+  
+  public IRI getScheme() {
+    String scheme = getAttributeValue("scheme");
+    return (scheme != null) ? new IRI(scheme) : null;
+  }
+  
+  public void setScheme(String scheme) {
+    if (scheme != null)
+      setAttributeValue("scheme",(new IRI(scheme)).toString());
+    else
+      removeAttribute(new QName("scheme"));
+  }
+
+  public String getRole() {
+    return getAttributeValue("role");
+  }
+  
+  public void setRole(String role) {
+    if (role != null)
+      setAttributeValue("role", role);
+    else 
+      removeAttribute(new QName("role"));
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaDescription.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaDescription.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaDescription.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaDescription.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,48 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class MediaDescription extends ElementWrapper {
+
+  public MediaDescription(Element internal) {
+    super(internal);
+  }
+
+  public MediaDescription(Factory factory) {
+    super(factory, MediaConstants.DESCRIPTION);
+  }
+  
+  public void setType(MediaConstants.Type type) {
+    switch(type) {
+      case PLAIN: setAttributeValue("type", "plain"); break;
+      case HTML:  setAttributeValue("type", "html"); break;
+      default:    removeAttribute(new QName("type"));
+    }
+  }
+  
+  public MediaConstants.Type getType() {
+    String type = getAttributeValue("type");
+    return (type != null) ? MediaConstants.Type.valueOf(type.toUpperCase()) : null;
+  }
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaExtensionFactory.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaExtensionFactory.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaExtensionFactory.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaExtensionFactory.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,47 @@
+/*
+* 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.media;
+
+import org.apache.abdera.util.AbstractExtensionFactory;
+
+public final class MediaExtensionFactory 
+  extends AbstractExtensionFactory
+  implements MediaConstants {
+  
+  @SuppressWarnings("deprecation")
+  public MediaExtensionFactory() {
+    super(MediaConstants.MEDIA_NS);
+    addImpl(ADULT,MediaAdult.class);
+    addImpl(CATEGORY,MediaCategory.class);
+    addImpl(CONTENT,MediaContent.class);
+    addImpl(COPYRIGHT,MediaCopyright.class);
+    addImpl(CREDIT,MediaCredit.class);
+    addImpl(DESCRIPTION,MediaDescription.class);
+    addImpl(GROUP,MediaGroup.class);
+    addImpl(HASH,MediaHash.class);
+    addImpl(KEYWORDS,MediaKeywords.class);
+    addImpl(PLAYER,MediaPlayer.class);
+    addImpl(RATING,MediaRating.class);
+    addImpl(RESTRICTION,MediaRestriction.class);
+    addImpl(TEXT,MediaText.class);
+    addImpl(THUMBNAIL,MediaThumbnail.class);
+    addImpl(TITLE,MediaTitle.class);
+  }
+
+}
+

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaGroup.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaGroup.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaGroup.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaGroup.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,34 @@
+/*
+* 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.media;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ExtensibleElementWrapper;
+
+public class MediaGroup extends ExtensibleElementWrapper {
+
+  public MediaGroup(Element internal) {
+    super(internal);
+  }
+
+  public MediaGroup(Factory factory) {
+    super(factory, MediaConstants.GROUP);
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaHash.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaHash.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaHash.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaHash.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,53 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class MediaHash extends ElementWrapper {
+
+  public MediaHash(Element internal) {
+    super(internal);
+  }
+
+  public MediaHash(Factory factory) {
+    super(factory, MediaConstants.HASH);
+  }
+  
+  public MediaConstants.Algo getAlgorithm() {
+    String algo = getAttributeValue("algo");
+    if (algo == null) return null;
+    if (algo.equalsIgnoreCase("sha-1")) return MediaConstants.Algo.SHA1;
+    if (algo.equalsIgnoreCase("md5")) return MediaConstants.Algo.MD5;
+    return null;
+  }
+  
+  public void setAlgorithm(MediaConstants.Algo algorithm) {
+    switch (algorithm) {
+      case SHA1: setAttributeValue("algo", "sha-1"); break;
+      case MD5: setAttributeValue("algo", "md5"); break;
+      default: removeAttribute(new QName("algo"));
+    }
+  }
+  
+  // TODO: Helper methods for calculating the hash
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaKeywords.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaKeywords.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaKeywords.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaKeywords.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,34 @@
+/*
+* 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.media;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class MediaKeywords extends ElementWrapper {
+
+  public MediaKeywords(Element internal) {
+    super(internal);
+  }
+
+  public MediaKeywords(Factory factory) {
+    super(factory, MediaConstants.KEYWORDS);
+  }
+  
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaPlayer.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaPlayer.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaPlayer.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaPlayer.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,75 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class MediaPlayer extends ElementWrapper {
+
+  public MediaPlayer(Element internal) {
+    super(internal);
+  }
+
+  public MediaPlayer(Factory factory) {
+    super(factory, MediaConstants.PLAYER);
+  }
+  
+  public IRI getUrl() {
+    String url = getAttributeValue("url");
+    return (url != null) ? new IRI(url) : null;
+  }
+  
+  public void setUrl(String url) {
+    if (url != null) {
+      setAttributeValue("url", (new IRI(url)).toString());
+    } else {
+      removeAttribute(new QName("url"));
+    }
+  }
+  
+  public int getWidth() {
+    String width = getAttributeValue("width");
+    return (width != null) ? Integer.parseInt(width) : -1;
+  }
+  
+  public void setWidth(int width) {
+    if (width > -1) {
+      setAttributeValue("width", String.valueOf(width));
+    } else {
+      removeAttribute(new QName("width"));
+    }
+  }
+  
+  public int getHeight() {
+    String height = getAttributeValue("height");
+    return (height != null) ? Integer.parseInt(height) : -1;
+  }
+  
+  public void setHeight(int height) {
+    if (height > -1) {
+      setAttributeValue("height", String.valueOf(height));
+    } else {
+      removeAttribute(new QName("height"));
+    }
+  }
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRating.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRating.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRating.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRating.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,56 @@
+/*
+* 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.media;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class MediaRating extends ElementWrapper {
+
+  public MediaRating(Element internal) {
+    super(internal);
+  }
+
+  public MediaRating(Factory factory) {
+    super(factory, MediaConstants.RATING);
+  }
+  
+  public IRI getScheme() {
+    String scheme = getAttributeValue("scheme");
+    return (scheme != null) ? new IRI(scheme) : null;
+  }
+  
+  public void setScheme(String scheme) {
+    setAttributeValue("scheme",(new IRI(scheme)).toString());
+  }
+  
+  public void setAdult(boolean adult) {
+    try {
+      setScheme("urn:simple");
+      setText(adult?"adult":"nonadult");
+    } catch (Exception e) {}
+  }
+  
+  public boolean isAdult() {
+    String scheme = getAttributeValue("scheme");
+    String text = getText();
+    return scheme.equals("urn:simple") && "adult".equalsIgnoreCase(text);
+  }
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRestriction.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRestriction.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRestriction.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaRestriction.java Mon Aug 20 17:51:20 2007
@@ -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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class MediaRestriction extends ElementWrapper {
+
+  public MediaRestriction(Element internal) {
+    super(internal);
+  }
+
+  public MediaRestriction(Factory factory) {
+    super(factory, MediaConstants.RESTRICTION);
+  }
+  
+  public void setRelationship(MediaConstants.Relationship type) {
+    switch(type) {
+      case ALLOW: setAttributeValue("relationship", "allow"); break;
+      case DENY:  setAttributeValue("relationship", "deny"); break;
+      default:    removeAttribute(new QName("relationship"));
+    }
+  }
+  
+  public MediaConstants.Relationship getRelationship() {
+    String rel = getAttributeValue("relationship");
+    return (rel != null) ? MediaConstants.Relationship.valueOf(rel.toUpperCase()) : null;
+  }
+  
+  public void setType(MediaConstants.RestrictionType type) {
+    switch(type) {
+      case COUNTRY: setAttributeValue("type", "country"); break;
+      case URI:  setAttributeValue("type", "uri"); break;
+      default:    removeAttribute(new QName("type"));
+    }
+  }
+  
+  public MediaConstants.RestrictionType getType() {
+    String type = getAttributeValue("type");
+    return (type != null) ? MediaConstants.RestrictionType.valueOf(type.toUpperCase()) : null;
+  }
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaText.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaText.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaText.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaText.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,81 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class MediaText extends ElementWrapper {
+
+  public MediaText(Element internal) {
+    super(internal);
+  }
+
+  public MediaText(Factory factory) {
+    super(factory, MediaConstants.TEXT);
+  }
+  
+  public void setType(MediaConstants.Type type) {
+    switch(type) {
+      case PLAIN: setAttributeValue("type", "plain"); break;
+      case HTML:  setAttributeValue("type", "html"); break;
+      default:    removeAttribute(new QName("type"));
+    }
+  }
+  
+  public MediaConstants.Type getType() {
+    String type = getAttributeValue("type");
+    return (type != null) ? MediaConstants.Type.valueOf(type.toUpperCase()) : null;
+  }
+  
+  public String getLang() {
+    return getAttributeValue("lang");
+  }
+  
+  public void setLang(String lang) {
+    if (lang != null)
+      setAttributeValue("lang", lang);
+    else
+      removeAttribute(new QName("lang"));
+  }
+  
+  public String getStart() {
+    return getAttributeValue("start");
+  }
+  
+  public void setStart(String start) {
+    if (start != null)
+      setAttributeValue("start", start);
+    else 
+      removeAttribute(new QName("start"));
+  }
+  
+  public String getEnd() {
+    return getAttributeValue("end");
+  }
+  
+  public void setEnd(String end) {
+    if (end != null)
+      setAttributeValue("end", end);
+    else
+      removeAttribute(new QName("end"));
+  }
+}

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaThumbnail.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaThumbnail.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaThumbnail.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaThumbnail.java Mon Aug 20 17:51:20 2007
@@ -0,0 +1,89 @@
+/*
+* 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.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+import org.apache.abdera.i18n.iri.IRI;
+
+public class MediaThumbnail extends ElementWrapper {
+
+  public MediaThumbnail(Element internal) {
+    super(internal);
+  }
+
+  public MediaThumbnail(Factory factory) {
+    super(factory, MediaConstants.THUMBNAIL);
+  }
+  
+  public IRI getUrl() {
+    String url = getAttributeValue("url");
+    return (url != null) ? new IRI(url) : null;
+  }
+  
+  public void setUrl(String url) {
+    if (url != null) {
+      setAttributeValue("url", (new IRI(url)).toString());
+    } else {
+      removeAttribute(new QName("url"));
+    }
+  }
+  
+  public int getWidth() {
+    String width = getAttributeValue("width");
+    return (width != null) ? Integer.parseInt(width) : -1;
+  }
+  
+  public void setWidth(int width) {
+    if (width > -1) {
+      setAttributeValue("width", String.valueOf(width));
+    } else {
+      removeAttribute(new QName("width"));
+    }
+  }
+  
+  public int getHeight() {
+    String height = getAttributeValue("height");
+    return (height != null) ? Integer.parseInt(height) : -1;
+  }
+  
+  public void setHeight(int height) {
+    if (height > -1) {
+      setAttributeValue("height", String.valueOf(height));
+    } else {
+      removeAttribute(new QName("height"));
+    }
+  }
+  
+  public String getTime() {
+    return getAttributeValue("time");
+  }
+  
+  public void setTime(String time) {
+    if (time != null)
+      setAttributeValue("time", time);
+    else 
+      removeAttribute(new QName("time"));
+  }
+  
+}
+
+

Added: incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaTitle.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaTitle.java?rev=567888&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaTitle.java (added)
+++ incubator/abdera/java/trunk/extensions/media/src/main/java/org/apache/abdera/ext/media/MediaTitle.java Mon Aug 20 17:51:20 2007
@@ -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.ext.media;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.factory.Factory;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
+
+public class MediaTitle extends ElementWrapper {
+
+  public MediaTitle(Element internal) {
+    super(internal);
+  }
+
+  public MediaTitle(Factory factory) {
+    super(factory, MediaConstants.TITLE);
+  }
+  
+  public void setType(MediaConstants.Type type) {
+    switch(type) {
+      case PLAIN: setAttributeValue("type", "plain"); break;
+      case HTML:  setAttributeValue("type", "html"); break;
+      default:    removeAttribute(new QName("type"));
+    }
+  }
+  
+  public MediaConstants.Type getType() {
+    String type = getAttributeValue("type");
+    return (type != null) ? MediaConstants.Type.valueOf(type.toUpperCase()) : null;
+  }
+  
+}