You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2008/03/04 14:40:26 UTC

svn commit: r633474 - in /incubator/sling/trunk/extensions: ./ apt/ apt/apt-parser/ apt/apt-parser/src/ apt/apt-parser/src/main/ apt/apt-parser/src/main/java/ apt/apt-parser/src/main/java/org/ apt/apt-parser/src/main/java/org/apache/ apt/apt-parser/src...

Author: bdelacretaz
Date: Tue Mar  4 05:40:21 2008
New Revision: 633474

URL: http://svn.apache.org/viewvc?rev=633474&view=rev
Log:
SLING-305, APT parser bundle

Added:
    incubator/sling/trunk/extensions/
    incubator/sling/trunk/extensions/apt/
    incubator/sling/trunk/extensions/apt/apt-parser/   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/pom.xml   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParseException.java   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParser.java   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptParser.java   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptSink.java   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/MacroResolver.java   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParseExceptionImpl.java   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParserImpl.java   (with props)
    incubator/sling/trunk/extensions/apt/apt-parser/src/test/
    incubator/sling/trunk/extensions/apt/apt-parser/src/test/java/
    incubator/sling/trunk/extensions/apt/apt-parser/src/test/java/org/
    incubator/sling/trunk/extensions/apt/apt-parser/src/test/java/org/apache/
    incubator/sling/trunk/extensions/apt/apt-parser/src/test/java/org/apache/sling/
    incubator/sling/trunk/extensions/apt/apt-parser/src/test/java/org/apache/sling/apt/
    incubator/sling/trunk/extensions/apt/apt-parser/src/test/java/org/apache/sling/apt/parser/

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Mar  4 05:40:21 2008
@@ -0,0 +1,10 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+

Added: incubator/sling/trunk/extensions/apt/apt-parser/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/pom.xml?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/pom.xml (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/pom.xml Tue Mar  4 05:40:21 2008
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+  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.
+-->
+<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">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>1-incubator-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <artifactId>org.apache.sling.extensions.apt.parser</artifactId>
+    <packaging>bundle</packaging>
+    <version>2.0.0-incubator-SNAPSHOT</version>
+
+    <name>Sling - APT parser</name>
+    <description>
+    	Parser for the Sling variant of the APT (Almost Plain Text) 
+    	structured text format.
+    </description>
+
+    <scm>
+        <connection>
+            scm:svn:http://svn.apache.org/repos/asf/incubator/sling/trunk/commons/apt-parser
+        </connection>
+        <developerConnection>
+            scm:svn:https://svn.apache.org/repos/asf/incubator/sling/trunk/commons/apt-parser
+        </developerConnection>
+        <url>
+            http://svn.apache.org/viewvc/incubator/sling/trunk/commons/apt-parser
+        </url>
+    </scm>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-scr-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            !org.apache.sling.apt.parser.internal,
+                            org.apache.sling.apt.parser.*
+                        </Export-Package>
+                        <Private-Package>
+                            org.apache.sling.apt.parser.internal,
+                            org.apache.maven.doxia.*
+                        </Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven.doxia</groupId>
+            <artifactId>doxia-module-apt</artifactId>
+            <version>1.0-alpha-10</version>
+        </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+</project>

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParseException.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParseException.java?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParseException.java (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParseException.java Tue Mar  4 05:40:21 2008
@@ -0,0 +1,37 @@
+/*
+ * 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.
+ */
+package org.apache.sling.apt.parser;
+
+/** Generic SlingAptParseException */
+public abstract class SlingAptParseException extends Exception {
+    
+    protected SlingAptParseException(String reason, Throwable cause) {
+        super(reason, cause);
+    }
+    
+    /**
+     * Returns the file that caused the exception
+     */
+    public abstract String getFileName();
+
+    /**
+     * Returns the line number where the exception ocurred.
+     */
+    public abstract int getLineNumber();
+}

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParseException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParseException.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParser.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParser.java?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParser.java (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParser.java Tue Mar  4 05:40:21 2008
@@ -0,0 +1,31 @@
+/*
+ * 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.
+ */
+package org.apache.sling.apt.parser;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+/** APT parser interface for Sling */
+public interface SlingAptParser {
+    /** Parse the given input, which must be in APT format, and
+     *  write the HTML result to output.
+     */
+    void parse(Reader input, Writer output) throws IOException, SlingAptParseException;
+}

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/SlingAptParser.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptParser.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptParser.java?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptParser.java (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptParser.java Tue Mar  4 05:40:21 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+package org.apache.sling.apt.parser.internal;
+
+import org.apache.maven.doxia.macro.Macro;
+import org.apache.maven.doxia.macro.MacroExecutionException;
+import org.apache.maven.doxia.macro.MacroRequest;
+import org.apache.maven.doxia.macro.manager.MacroNotFoundException;
+import org.apache.maven.doxia.module.apt.AptParser;
+import org.apache.maven.doxia.sink.Sink;
+
+/** Customize the doxia APT parser to use our MacroResolver */
+class CustomAptParser extends AptParser{
+
+    private final MacroResolver macroProvider;
+
+    /** Instead of throwing an Exception we execute this Macro
+     *  if we didn't find the requested one
+     */ 
+    static class DefaultMacro implements Macro {
+        private final String id;
+        
+        DefaultMacro(String id) {
+            this.id = id;
+        }
+        
+        public void execute(Sink sink, MacroRequest request) throws MacroExecutionException {
+            sink.text("APT macro not found: '" + id + "'");
+        }
+    }
+    
+    CustomAptParser(MacroResolver mp) {
+        macroProvider = mp;
+    }
+
+    @Override
+    public void executeMacro( String macroId, MacroRequest request, Sink sink )
+    throws MacroExecutionException, MacroNotFoundException
+    {
+        Macro m = macroProvider.resolveMacro(macroId);
+        if(m == null) {
+            m = new DefaultMacro(macroId);
+        }
+        m.execute( sink, request );
+    }
+}

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptParser.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptParser.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptSink.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptSink.java?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptSink.java (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptSink.java Tue Mar  4 05:40:21 2008
@@ -0,0 +1,126 @@
+/*
+ * 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.
+ */
+package org.apache.sling.apt.parser.internal;
+
+import java.io.Writer;
+
+import org.apache.maven.doxia.module.apt.AptSink;
+
+/** AptSink which outputs (X)HTML */
+class CustomAptSink extends AptSink {
+    
+    CustomAptSink(Writer w) {
+        super(w);
+    }
+    
+    @Override
+    public void sectionTitle1() {
+        write("<h1>");
+    }
+
+    @Override
+    public void sectionTitle1_() {
+        write("</h1>");
+    }
+    
+    @Override
+    public void sectionTitle2_() {
+        write("</h2>");
+    }
+
+    @Override
+    public void sectionTitle2() {
+        write("<h2>");
+    }
+
+    @Override
+    public void sectionTitle3_() {
+        write("</h3>");
+    }
+
+    @Override
+    public void sectionTitle3() {
+        write("<h3>");
+    }
+
+    @Override
+    public void sectionTitle4_() {
+        write("</h4>");
+    }
+
+    @Override
+    public void sectionTitle4() {
+        write("<h4>");
+    }
+
+    @Override
+    public void list_() {
+        write("</ul>");
+    }
+
+    @Override
+    public void list() {
+        write("<ul>");
+    }
+
+    @Override
+    public void listItem_() {
+        write("</li>");
+    }
+
+    @Override
+    public void listItem() {
+        write("<li>");
+    }
+
+    
+    @Override
+    public void head_() {
+    }
+
+    @Override
+    public void head() {
+    }
+
+    @Override
+    public void paragraph_() {
+        write("</p>");
+    }
+
+    @Override
+    public void paragraph() {
+        write("<p>");
+    }
+
+    @Override
+    public void link(String name) {
+        write("<a href=\"" + name + "\">");
+    }
+
+    @Override
+    public void link_() {
+        write("</a>");
+    }
+    
+    @Override
+    public void horizontalRule() {
+        write("<hr/>\n");
+    }
+
+}
\ No newline at end of file

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptSink.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/CustomAptSink.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/MacroResolver.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/MacroResolver.java?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/MacroResolver.java (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/MacroResolver.java Tue Mar  4 05:40:21 2008
@@ -0,0 +1,26 @@
+/*
+ * 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.
+ */
+package org.apache.sling.apt.parser.internal;
+
+import org.apache.maven.doxia.macro.Macro;
+
+/** Simple provider of APT Macro objects */
+interface MacroResolver {
+    Macro resolveMacro(String macroId);
+}

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/MacroResolver.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/MacroResolver.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParseExceptionImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParseExceptionImpl.java?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParseExceptionImpl.java (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParseExceptionImpl.java Tue Mar  4 05:40:21 2008
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.apt.parser.internal;
+
+import org.apache.maven.doxia.module.apt.AptParseException;
+import org.apache.sling.apt.parser.SlingAptParseException;
+
+/** SlingAptParseException that wraps a doxia AptParseException */
+class SlingAptParseExceptionImpl extends SlingAptParseException {
+    private final AptParseException ape;
+    
+    SlingAptParseExceptionImpl(AptParseException ape) {
+        super(ape.getMessage(), ape.getCause());
+        this.ape = ape;
+    }
+
+    @Override
+    public String getFileName() {
+        return ape.getFileName();
+    }
+
+    @Override
+    public int getLineNumber() {
+        return ape.getLineNumber();
+    }
+
+}

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParseExceptionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParseExceptionImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Added: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParserImpl.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParserImpl.java?rev=633474&view=auto
==============================================================================
--- incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParserImpl.java (added)
+++ incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParserImpl.java Tue Mar  4 05:40:21 2008
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+package org.apache.sling.apt.parser.internal;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.Writer;
+
+import org.apache.maven.doxia.module.apt.AptParseException;
+import org.apache.maven.doxia.module.apt.AptParser;
+import org.apache.maven.doxia.sink.Sink;
+import org.apache.sling.apt.parser.SlingAptParseException;
+import org.apache.sling.apt.parser.SlingAptParser;
+
+/** SlingAptParser implementation, provided as an SCR service
+ * 
+*   @scr.component label="Sling APT parser" 
+*       description="Converts APT documents to HTML format"
+*   @scr.property name="service.vendor" value="The Apache Software Foundation"
+*   @scr.property name="service.description"
+*       value="Sling APT structured text parser"
+*
+*   @scr.service
+*/
+
+public class SlingAptParserImpl implements SlingAptParser {
+
+    private final MacroResolver macroProvider;
+    
+    public SlingAptParserImpl() {
+        macroProvider = null;
+    }
+    
+    SlingAptParserImpl(MacroResolver mp) {
+        macroProvider = mp;
+    }
+    
+    public void parse(Reader input, Writer output) throws IOException, SlingAptParseException {
+        final Sink sink = new CustomAptSink(output);
+        final AptParser parser = new CustomAptParser(macroProvider);
+        try {
+            parser.parse(input, sink);
+        } catch(AptParseException ape) {
+            throw new SlingAptParseExceptionImpl(ape);
+        }
+    }
+
+}

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParserImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/extensions/apt/apt-parser/src/main/java/org/apache/sling/apt/parser/internal/SlingAptParserImpl.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL