You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by si...@apache.org on 2012/04/05 17:43:11 UTC
svn commit: r1309903 -
/commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java
Author: simonetripodi
Date: Thu Apr 5 15:43:10 2012
New Revision: 1309903
URL: http://svn.apache.org/viewvc?rev=1309903&view=rev
Log:
first checkin of a CodeWriter based on annotations processor Filer
Added:
commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java (with props)
Added: commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java
URL: http://svn.apache.org/viewvc/commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java?rev=1309903&view=auto
==============================================================================
--- commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java (added)
+++ commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java Thu Apr 5 15:43:10 2012
@@ -0,0 +1,67 @@
+package org.apache.commons.digester3.annotations.processor;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. 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.
+ */
+
+import static java.lang.String.format;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import javax.annotation.processing.Filer;
+
+import com.sun.codemodel.CodeWriter;
+import com.sun.codemodel.JPackage;
+
+/**
+ * @since 3.3
+ */
+final class FilerCodeWriter
+ extends CodeWriter
+{
+
+ /**
+ * Java source file extension.
+ */
+ private static final String JAVA_FILE_EXTENSION = ".java";
+
+ private final Filer filer;
+
+ public FilerCodeWriter( Filer filer )
+ {
+ this.filer = filer;
+ }
+
+ @Override
+ public OutputStream openBinary( JPackage pkg, String fileName )
+ throws IOException
+ {
+ String className = fileName.substring( 0, fileName.length() - JAVA_FILE_EXTENSION.length() );
+
+ return filer.createSourceFile( format( "%s.%s", pkg.name(), className ) ).openOutputStream();
+ }
+
+ @Override
+ public void close()
+ throws IOException
+ {
+ // do nothing
+ }
+
+}
Propchange: commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: commons/proper/digester/trunk/annotations-processor/src/main/java/org/apache/commons/digester3/annotations/processor/FilerCodeWriter.java
------------------------------------------------------------------------------
svn:mime-type = text/plain