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/09/13 20:49:42 UTC
svn commit: r575400 [2/3] - in
/incubator/abdera/java/trunk/extensions/converters: ./ src/ src/main/
src/main/java/ src/main/java/org/ src/main/java/org/apache/
src/main/java/org/apache/abdera/ src/main/java/org/apache/abdera/converter/
src/main/java/o...
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Name.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Name.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Name.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Name.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,30 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*name")
+public @interface Name {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Published.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Published.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Published.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Published.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,30 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*published")
+public @interface Published {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rel.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rel.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rel.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rel.java Thu Sep 13 11:49:38 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*rel")
+public @interface Rel {
+ String value() default "##default";
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rights.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rights.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rights.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Rights.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,31 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*rights")
+public @interface Rights {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Scheme.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Scheme.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Scheme.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Scheme.java Thu Sep 13 11:49:38 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*scheme")
+public @interface Scheme {
+ String value() default "##default";
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Service.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Service.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Service.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Service.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,29 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE})
+@Convention(".*service")
+public @interface Service {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Source.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Source.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Source.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Source.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,31 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*source")
+public @interface Source {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Src.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Src.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Src.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Src.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,30 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*src")
+public @interface Src {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Subtitle.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Subtitle.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Subtitle.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Subtitle.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,31 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*subtitle")
+public @interface Subtitle {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Summary.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Summary.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Summary.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Summary.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,31 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*summary")
+public @interface Summary {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Term.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Term.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Term.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Term.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,30 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*term")
+public @interface Term {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/TextType.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/TextType.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/TextType.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/TextType.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,35 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import org.apache.abdera.model.Text;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*texttype")
+public @interface TextType {
+ Text.Type value() default Text.Type.TEXT;
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Title.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Title.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Title.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Title.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,31 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*title")
+public @interface Title {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/URI.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/URI.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/URI.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/URI.java Thu Sep 13 11:49:38 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*uri")
+public @interface URI {
+ String value() default "##default";
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Updated.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Updated.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Updated.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Updated.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,30 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*updated")
+public @interface Updated {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Value.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Value.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Value.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Value.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,31 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+import static java.lang.annotation.ElementType.TYPE;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*value")
+public @interface Value {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Version.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Version.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Version.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Version.java Thu Sep 13 11:49:38 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({METHOD,FIELD})
+@Convention(".*version")
+public @interface Version {
+ String value() default "##default";
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Workspace.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Workspace.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Workspace.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/annotation/Workspace.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,31 @@
+/*
+* 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.converter.annotation;
+
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.FIELD;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+@Retention(RUNTIME)
+@Target({TYPE,METHOD,FIELD})
+@Convention(".*workspace")
+public @interface Workspace {}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/CategoryConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/CategoryConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/CategoryConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/CategoryConverter.java Thu Sep 13 11:49:38 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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.converter.BaseConverter;
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.Label;
+import org.apache.abdera.converter.annotation.Scheme;
+import org.apache.abdera.converter.annotation.Term;
+import org.apache.abdera.model.Category;
+
+public class CategoryConverter
+ extends BaseConverter<Category> {
+
+ @Override
+ protected Category create(
+ ConversionContext context) {
+ return context.getAbdera().getFactory()
+ .newCategory(null);
+ }
+
+ @Override
+ protected void finish(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Category dest) {
+ String term = dest.getTerm();
+ if (term == null) {
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(source, objectContext, context);
+ if (v != null) dest.setTerm(v.toString());
+ }
+
+ if (dest.getScheme() == null) {
+ Scheme ra = objectContext.getAnnotation(Scheme.class);
+ if (ra != null && !ra.value().equals("##default")) {
+ dest.setScheme(ra.value());
+ }
+ }
+
+ }
+
+ @Override
+ protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ Category dest,
+ AccessibleObject accessor) {
+ if (accessor.isAnnotationPresent(Term.class) ||
+ Term.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setTerm(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(Scheme.class) ||
+ Scheme.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setScheme(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(Label.class) ||
+ Label.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setLabel(v.toString());
+ }
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/ContentConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/ContentConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/ContentConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/ContentConverter.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,180 @@
+/*
+* 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.converter.impl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.lang.reflect.AccessibleObject;
+import java.net.URI;
+import java.net.URL;
+import java.nio.channels.Channels;
+import java.nio.channels.ReadableByteChannel;
+
+import javax.activation.DataHandler;
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.converter.BaseConverter;
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.ContentType;
+import org.apache.abdera.converter.annotation.MediaType;
+import org.apache.abdera.converter.annotation.Value;
+import org.apache.abdera.i18n.io.InputStreamDataSource;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Content;
+import org.apache.abdera.model.Div;
+import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+
+@SuppressWarnings("unchecked")
+public class ContentConverter
+ extends BaseConverter<Content> {
+
+ @Override
+ protected Content create(
+ ConversionContext context) {
+ return context.getAbdera().getFactory()
+ .newContent((Content.Type)null, null);
+ }
+
+ @Override
+ protected void init(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Content dest) {
+ ContentType ct = objectContext.getAnnotation(ContentType.class);
+ MediaType mt = objectContext.getAnnotation(MediaType.class);
+ if (ct != null) dest.setContentType(ct.value());
+ setValue(source,dest,false,null,null);
+ if (mt != null) dest.setMimeType(mt.value());
+ }
+
+ @Override
+ protected void finish(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Content dest) {
+ String set = dest.getAttributeValue("set");
+ dest.removeAttribute(new QName("set"));
+ if ("no".equals(set)) setValue(source,dest,true,objectContext,context);
+ }
+
+ @Override
+ protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ Content dest,
+ AccessibleObject accessor) {
+
+ String set = dest.getAttributeValue("set");
+ if (!"no".equals(set)) return;
+
+ if (accessor.isAnnotationPresent(Value.class) ||
+ Value.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ setValue(value, dest, true, valueContext, context);
+ } else if (accessor.isAnnotationPresent(ContentType.class) ||
+ ContentType.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ContentType ct = objectContext.getAnnotation(ContentType.class);
+ if (value == null || ct != null) return;
+ if (value instanceof Content.Type) {
+ dest.setContentType((Content.Type)value);
+ } else {
+ Content.Type type = Content.Type.valueOf(value.toString().toUpperCase());
+ dest.setContentType(type);
+ }
+ }
+
+ }
+
+ private void setValue(
+ Object source,
+ Content dest,
+ boolean convertOther,
+ ObjectContext sourceContext,
+ ConversionContext context) {
+ if (source == null) return;
+ try {
+ if (source instanceof String) {
+ dest.setValue(source.toString());
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof StringBuffer) {
+ dest.setValue(source.toString());
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof DataHandler) {
+ DataHandler dh = (DataHandler) source;
+ dest.setText(dh);
+ dest.setMimeType(dh.getContentType());
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof InputStream) {
+ DataHandler dh = new DataHandler(new InputStreamDataSource((InputStream)source));
+ dest.setText(dh);
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof Reader) {
+ Reader rdr = (Reader)source;
+ StringBuffer buf = new StringBuffer();
+ char[] chars = new char[100];
+ int r = -1;
+ while ((r = rdr.read(chars)) != -1) buf.append(chars, 0, r);
+ dest.setValue(buf.toString());
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof ReadableByteChannel) {
+ InputStream in = Channels.newInputStream((ReadableByteChannel) source);
+ DataHandler dh = new DataHandler(new InputStreamDataSource(in));
+ dest.setText(dh);
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof Div) {
+ dest.setValueElement((Div)source);
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof Element) {
+ dest.setValueElement((Element)source);
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof Document) {
+ Element root = ((Document)source).getRoot();
+ if (root != null) dest.setValueElement(root);
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof URI) {
+ dest.setSrc(source.toString());
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof URL) {
+ dest.setSrc(source.toString());
+ dest.removeAttribute(new QName("set"));
+ } else if (source instanceof IRI) {
+ dest.setSrc(source.toString());
+ dest.removeAttribute(new QName("set"));
+ } else {
+ if (convertOther) {
+ StringConverter c = new StringConverter();
+ StringBuffer buf = c.convert(source, sourceContext, context);
+ if (buf != null) dest.setValue(buf.toString());
+ dest.removeAttribute(new QName("set"));
+ } else dest.setAttributeValue("set", "no");
+ }
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/DateTimeConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/DateTimeConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/DateTimeConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/DateTimeConverter.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,95 @@
+/*
+* 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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+import java.util.Calendar;
+import java.util.Date;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.Value;
+import org.apache.abdera.model.AtomDate;
+import org.apache.abdera.model.DateTime;
+
+public class DateTimeConverter
+ extends QNameConverter<DateTime> {
+
+ protected DateTimeConverter(QName qname) {
+ super(qname);
+ }
+
+ @Override
+ protected DateTime create(
+ ConversionContext context) {
+ return context.getAbdera().getFactory()
+ .newDateTime(getQName(), null);
+ }
+
+ @Override
+ protected void finish(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ DateTime dest) {
+ String text = dest.getText();
+ if (text == null || text.trim().length() == 0) {
+ setValue(source, objectContext, context, dest);
+ }
+ }
+
+ @Override
+ protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ DateTime dest,
+ AccessibleObject accessor) {
+ if (accessor.isAnnotationPresent(Value.class) ||
+ Value.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value);
+ setValue(source, valueContext, context, dest);
+ }
+ }
+
+ private void setValue(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ DateTime dest) {
+ if (source == null) return;
+ if (source instanceof Date) {
+ dest.setDate((Date)source);
+ } else if (source instanceof Calendar) {
+ dest.setCalendar((Calendar)source);
+ } else if (source instanceof Long) {
+ dest.setTime((Long)source);
+ } else if (source instanceof String) {
+ dest.setValue(AtomDate.valueOf((String)source));
+ } else {
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(source, objectContext, context);
+ if (v != null) dest.setValue(AtomDate.valueOf(v.toString()));
+ }
+ }
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/EntryConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/EntryConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/EntryConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/EntryConverter.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,184 @@
+/*
+* 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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.converter.BaseConverter;
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.Author;
+import org.apache.abdera.converter.annotation.Category;
+import org.apache.abdera.converter.annotation.Content;
+import org.apache.abdera.converter.annotation.Contributor;
+import org.apache.abdera.converter.annotation.Edited;
+import org.apache.abdera.converter.annotation.ID;
+import org.apache.abdera.converter.annotation.Link;
+import org.apache.abdera.converter.annotation.Published;
+import org.apache.abdera.converter.annotation.Rights;
+import org.apache.abdera.converter.annotation.Summary;
+import org.apache.abdera.converter.annotation.Title;
+import org.apache.abdera.converter.annotation.Updated;
+import org.apache.abdera.model.DateTime;
+import org.apache.abdera.model.Entry;
+import org.apache.abdera.model.IRIElement;
+import org.apache.abdera.model.Person;
+import org.apache.abdera.model.Text;
+import org.apache.abdera.util.Constants;
+
+public class EntryConverter
+ extends BaseConverter<Entry> {
+
+ @Override
+ protected Entry create(
+ ConversionContext context) {
+ return context.getAbdera().newEntry();
+ }
+
+ @Override protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ Entry entry,
+ AccessibleObject accessor) {
+
+ if (accessor.isAnnotationPresent(ID.class) ||
+ ID.class.equals(conventions.matchConvention(accessor))) {
+ IRIConverter c = new IRIConverter(Constants.ID);
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ IRIElement iri = c.convert(value, valueContext, context);
+ entry.setIdElement(iri);
+ }
+
+ else if (accessor.isAnnotationPresent(Title.class) ||
+ Title.class.equals(conventions.matchConvention(accessor))) {
+ TextConverter c = new TextConverter(Constants.TITLE);
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ Text text = c.convert(value, valueContext, context);
+ entry.setTitleElement(text);
+ }
+
+ else if (accessor.isAnnotationPresent(Summary.class) ||
+ Summary.class.equals(conventions.matchConvention(accessor))) {
+ TextConverter c = new TextConverter(Constants.SUBTITLE);
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ Text text = c.convert(value, valueContext, context);
+ entry.setSummaryElement(text);
+ }
+
+ else if (accessor.isAnnotationPresent(Rights.class) ||
+ Rights.class.equals(conventions.matchConvention(accessor))) {
+ TextConverter c = new TextConverter(Constants.RIGHTS);
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ Text text = c.convert(value, valueContext, context);
+ entry.setRightsElement(text);
+ }
+
+ else if (accessor.isAnnotationPresent(Updated.class) ||
+ Updated.class.equals(conventions.matchConvention(accessor))) {
+ DateTimeConverter c = new DateTimeConverter(Constants.UPDATED);
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ DateTime dt = c.convert(value, valueContext, context);
+ entry.setUpdatedElement(dt);
+ }
+
+ else if (accessor.isAnnotationPresent(Published.class) ||
+ Published.class.equals(conventions.matchConvention(accessor))) {
+ DateTimeConverter c = new DateTimeConverter(Constants.PUBLISHED);
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ DateTime dt = c.convert(value, valueContext, context);
+ entry.setPublishedElement(dt);
+ }
+
+ else if (accessor.isAnnotationPresent(Edited.class) ||
+ Edited.class.equals(conventions.matchConvention(accessor))) {
+ DateTimeConverter c = new DateTimeConverter(Constants.EDITED);
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ DateTime dt = c.convert(value, valueContext, context);
+ entry.setEditedElement(dt);
+ }
+
+ else if (accessor.isAnnotationPresent(Link.class) ||
+ Link.class.equals(conventions.matchConvention(accessor))) {
+ LinkConverter c = new LinkConverter();
+ Object val = eval(accessor, source);
+ Object[] values = toArray(val);
+ for (Object value : values) {
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ org.apache.abdera.model.Link link = c.convert(value, valueContext, context);
+ if (link != null) entry.addLink(link);
+ }
+ }
+
+ else if (accessor.isAnnotationPresent(Category.class) ||
+ Category.class.equals(conventions.matchConvention(accessor))) {
+ CategoryConverter c = new CategoryConverter();
+ Object val = eval(accessor, source);
+ Object[] values = toArray(val);
+ for (Object value : values) {
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ org.apache.abdera.model.Category category = c.convert(value, valueContext, context);
+ if (category != null) entry.addCategory(category);
+ }
+ }
+
+ else if (accessor.isAnnotationPresent(Author.class) ||
+ Author.class.equals(conventions.matchConvention(accessor))) {
+ PersonConverter c = new PersonConverter(Constants.AUTHOR);
+ Object val = eval(accessor, source);
+ Object[] values = toArray(val);
+ for (Object value : values) {
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ Person person = c.convert(value, valueContext, context);
+ if (person != null) entry.addAuthor(person);
+ }
+ }
+
+ else if (accessor.isAnnotationPresent(Contributor.class) ||
+ Contributor.class.equals(conventions.matchConvention(accessor))) {
+ PersonConverter c = new PersonConverter(Constants.CONTRIBUTOR);
+ Object val = eval(accessor, source);
+ Object[] values = toArray(val);
+ for (Object value : values) {
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ Person person = c.convert(value, valueContext, context);
+ if (person != null) entry.addContributor(person);
+ }
+ }
+
+ else if (accessor.isAnnotationPresent(Content.class) ||
+ Content.class.equals(conventions.matchConvention(accessor))) {
+ ContentConverter c = new ContentConverter();
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ org.apache.abdera.model.Content content = c.convert(value, valueContext, context);
+ entry.setContentElement(content);
+ }
+
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/FeedConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/FeedConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/FeedConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/FeedConverter.java Thu Sep 13 11:49:38 2007
@@ -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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.Entry;
+import org.apache.abdera.model.Feed;
+import org.apache.abdera.model.Source;
+
+public class FeedConverter
+ extends SourceConverter {
+
+ @Override
+ protected Source create(
+ ConversionContext context) {
+ return context.getAbdera().newFeed();
+ }
+
+ @Override protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ Source feed,
+ AccessibleObject accessor) {
+
+ if (accessor.isAnnotationPresent(Entry.class) ||
+ Entry.class.equals(conventions.matchConvention(accessor))) {
+ EntryConverter c = new EntryConverter();
+ Object val = eval(accessor, source);
+ Object[] values = toArray(val);
+ for (Object value : values) {
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ org.apache.abdera.model.Entry entry = c.convert(value, valueContext, context);
+ if (entry != null) ((Feed)feed).addEntry(entry);
+ }
+ }
+
+ else super.process(
+ source,
+ objectContext,
+ context,
+ conventions,
+ feed,
+ accessor);
+
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/GeneratorConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/GeneratorConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/GeneratorConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/GeneratorConverter.java Thu Sep 13 11:49:38 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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import org.apache.abdera.converter.BaseConverter;
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.URI;
+import org.apache.abdera.converter.annotation.Value;
+import org.apache.abdera.converter.annotation.Version;
+import org.apache.abdera.model.Generator;
+
+public class GeneratorConverter
+ extends BaseConverter<Generator> {
+
+ @Override
+ protected Generator create(
+ ConversionContext context) {
+ return context.getAbdera().getFactory()
+ .newGenerator(null);
+ }
+
+ @Override
+ protected void finish(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Generator dest) {
+ String text = dest.getText();
+ if (text == null || text.length() == 0) {
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(source, objectContext, context);
+ if (v != null) dest.setText(v.toString());
+ }
+
+ org.apache.abdera.converter.annotation.Generator gen =
+ objectContext.getAnnotation(org.apache.abdera.converter.annotation.Generator.class);
+ if (dest.getVersion() == null && gen != null) {
+ if (!gen.version().equals("##default"))
+ dest.setVersion(gen.version());
+ }
+ if (dest.getUri() == null && gen != null) {
+ if (!gen.uri().equals("##default"))
+ dest.setUri(gen.uri());
+ }
+
+ }
+
+ @Override
+ protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ Generator dest,
+ AccessibleObject accessor) {
+ if (accessor.isAnnotationPresent(Value.class) ||
+ Value.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setText(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(Version.class) ||
+ Version.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setVersion(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(URI.class) ||
+ URI.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setUri(v.toString());
+ }
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/IRIConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/IRIConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/IRIConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/IRIConverter.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,77 @@
+/*
+* 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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.Value;
+import org.apache.abdera.model.IRIElement;
+
+public class IRIConverter
+ extends QNameConverter<IRIElement> {
+
+ protected IRIConverter(QName qname) {
+ super(qname);
+ }
+
+ @Override
+ protected IRIElement create(
+ ConversionContext context) {
+ return context.getAbdera().getFactory()
+ .newIRIElement(getQName(), null);
+ }
+
+ @Override
+ protected void finish(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ IRIElement dest) {
+ String text = dest.getText();
+ if (text == null || text.trim().length() == 0)
+ dest.setValue(source.toString());
+ }
+
+ @Override
+ protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ IRIElement dest,
+ AccessibleObject accessor) {
+
+ if (accessor.isAnnotationPresent(Value.class) ||
+ Value.class.equals(conventions.matchConvention(accessor))) {
+
+ StringConverter c = new StringConverter();
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value);
+ StringBuffer result = c.convert(value, valueContext, context);
+ if (result != null) dest.setValue(result.toString());
+ }
+
+ }
+
+
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/LinkConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/LinkConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/LinkConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/LinkConverter.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,153 @@
+/*
+* 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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import javax.activation.MimeType;
+
+import org.apache.abdera.converter.BaseConverter;
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.Href;
+import org.apache.abdera.converter.annotation.HrefLanguage;
+import org.apache.abdera.converter.annotation.Length;
+import org.apache.abdera.converter.annotation.MediaType;
+import org.apache.abdera.converter.annotation.Rel;
+import org.apache.abdera.converter.annotation.Title;
+import org.apache.abdera.i18n.iri.IRI;
+import org.apache.abdera.model.Link;
+
+public class LinkConverter
+ extends BaseConverter<Link> {
+
+ @Override
+ protected Link create(
+ ConversionContext context) {
+ return context.getAbdera().getFactory()
+ .newLink(null);
+ }
+
+ @Override
+ protected void finish(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Link dest) {
+ IRI href = dest.getHref();
+ if (href == null) {
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(source, objectContext, context);
+ if (v != null) dest.setHref(v.toString());
+ }
+
+ if (dest.getRel() == null) {
+ Rel ra = objectContext.getAnnotation(Rel.class);
+ if (ra != null && !ra.value().equals("##default")) {
+ dest.setRel(ra.value());
+ }
+ }
+
+ if (dest.getMimeType() == null) {
+ MediaType mt = objectContext.getAnnotation(MediaType.class);
+ if (mt != null && !mt.value().equals("##default")) {
+ dest.setMimeType(mt.value());
+ }
+ }
+ }
+
+ @Override
+ protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ Link dest,
+ AccessibleObject accessor) {
+ if (accessor.isAnnotationPresent(Href.class) ||
+ Href.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setHref(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(MediaType.class) ||
+ MediaType.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ if (value != null && value instanceof MimeType) {
+ dest.setMimeType(value.toString());
+ } else {
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setMimeType(v.toString());
+ }
+ }
+
+ if (accessor.isAnnotationPresent(Title.class) ||
+ Title.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setTitle(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(HrefLanguage.class) ||
+ HrefLanguage.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setHrefLang(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(Rel.class) ||
+ Rel.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setRel(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(Length.class) ||
+ Length.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ if (value instanceof Long) {
+ dest.setLength((Long)value);
+ } else if (value instanceof Integer) {
+ Integer i = (Integer)value;
+ dest.setLength(i.intValue());
+ } else if (value instanceof Short) {
+ Short s = (Short)value;
+ dest.setLength(s.shortValue());
+ } else {
+ ObjectContext valueContext = new ObjectContext(value,source,accessor);
+ StringConverter s = new StringConverter();
+ StringBuffer v = s.convert(value, valueContext, context);
+ if (v != null) dest.setLength(Long.parseLong(v.toString()));
+ }
+ }
+
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/PersonConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/PersonConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/PersonConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/PersonConverter.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,98 @@
+/*
+* 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.converter.impl;
+
+import java.lang.reflect.AccessibleObject;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.converter.Conventions;
+import org.apache.abdera.converter.ConversionContext;
+import org.apache.abdera.converter.ObjectContext;
+import org.apache.abdera.converter.annotation.Email;
+import org.apache.abdera.converter.annotation.Name;
+import org.apache.abdera.converter.annotation.URI;
+import org.apache.abdera.model.IRIElement;
+import org.apache.abdera.model.Person;
+import org.apache.abdera.util.Constants;
+
+public class PersonConverter
+ extends QNameConverter<Person> {
+
+ protected PersonConverter(QName qname) {
+ super(qname);
+ }
+
+ @Override
+ protected Person create(
+ ConversionContext context) {
+ return context.getAbdera().getFactory()
+ .newPerson(getQName(), null);
+ }
+
+ @Override
+ protected void finish(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Person dest) {
+ String name = dest.getName();
+ if (name == null) {
+ StringConverter c = new StringConverter();
+ StringBuffer v = c.convert(source, objectContext, context);
+ if (v != null) dest.setName(v.toString());
+ }
+ }
+
+ @Override
+ protected void process(
+ Object source,
+ ObjectContext objectContext,
+ ConversionContext context,
+ Conventions conventions,
+ Person dest,
+ AccessibleObject accessor) {
+ if (accessor.isAnnotationPresent(Name.class) ||
+ Name.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value);
+ StringConverter c = new StringConverter();
+ StringBuffer v = c.convert(value, valueContext, context);
+ if (v != null) dest.setName(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(Email.class) ||
+ Email.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value);
+ StringConverter c = new StringConverter();
+ StringBuffer v = c.convert(value, valueContext, context);
+ if (v != null) dest.setEmail(v.toString());
+ }
+
+ if (accessor.isAnnotationPresent(URI.class) ||
+ URI.class.equals(conventions.matchConvention(accessor))) {
+ Object value = eval(accessor, source);
+ ObjectContext valueContext = new ObjectContext(value);
+ IRIConverter c = new IRIConverter(Constants.URI);
+ IRIElement iri = c.convert(value, valueContext, context);
+ if (iri != null) dest.setUriElement(iri);
+ }
+ }
+
+}
Added: incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/QNameConverter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/QNameConverter.java?rev=575400&view=auto
==============================================================================
--- incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/QNameConverter.java (added)
+++ incubator/abdera/java/trunk/extensions/converters/src/main/java/org/apache/abdera/converter/impl/QNameConverter.java Thu Sep 13 11:49:38 2007
@@ -0,0 +1,36 @@
+/*
+* 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.converter.impl;
+
+import javax.xml.namespace.QName;
+
+import org.apache.abdera.converter.BaseConverter;
+
+public abstract class QNameConverter<T>
+ extends BaseConverter<T> {
+
+ protected final QName qname;
+
+ protected QNameConverter(QName qname) {
+ this.qname = qname;
+ }
+
+ protected QName getQName() {
+ return qname;
+ }
+}