[jboss-svn-commits] JBoss Common SVN: r4253 - in jboss-i18ntool/trunk: src and 7 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri Apr 9 14:58:49 EDT 2010


Author: david.lloyd at jboss.com
Date: 2010-04-09 14:58:49 -0400 (Fri, 09 Apr 2010)
New Revision: 4253

Added:
   jboss-i18ntool/trunk/pom.xml
   jboss-i18ntool/trunk/src/
   jboss-i18ntool/trunk/src/main/
   jboss-i18ntool/trunk/src/main/java/
   jboss-i18ntool/trunk/src/main/java/org/
   jboss-i18ntool/trunk/src/main/java/org/jboss/
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/I18nProcessor.java
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/LogMessage.java
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Message.java
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageBundle.java
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageLogger.java
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translation.java
   jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translations.java
   jboss-i18ntool/trunk/src/test/
   jboss-i18ntool/trunk/src/test/java/
Log:
Import I18ntool project

Added: jboss-i18ntool/trunk/pom.xml
===================================================================
--- jboss-i18ntool/trunk/pom.xml	                        (rev 0)
+++ jboss-i18ntool/trunk/pom.xml	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.jboss.i18n</groupId>
+    <artifactId>jboss-i18n-tool</artifactId>
+    <version>1.0.0.Beta1-SNAPSHOT</version>
+
+    <name>JBoss I18n Tool</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>com.sun</groupId>
+            <artifactId>tools</artifactId>
+            <version>1.6.0</version>
+            <scope>system</scope>
+            <systemPath>${java.home}/../lib/tools.jar</systemPath>
+        </dependency>
+    </dependencies>
+</project>

Added: jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/I18nProcessor.java
===================================================================
--- jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/I18nProcessor.java	                        (rev 0)
+++ jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/I18nProcessor.java	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.i18ntool;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import org.jboss.i18ntool.annotation.LogMessage;
+import org.jboss.i18ntool.annotation.Message;
+import org.jboss.i18ntool.annotation.MessageBundle;
+import org.jboss.i18ntool.annotation.MessageLogger;
+import org.jboss.i18ntool.annotation.Translation;
+import org.jboss.i18ntool.annotation.Translations;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.Completion;
+import javax.annotation.processing.Processor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.AnnotationMirror;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+
+/**
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+public final class I18nProcessor extends AbstractProcessor implements Processor {
+
+    public Set<String> getSupportedAnnotationTypes() {
+        return new HashSet<String>(Arrays.asList(
+                LogMessage.class.getName(),
+                Message.class.getName(),
+                MessageBundle.class.getName(),
+                MessageLogger.class.getName(),
+                Translation.class.getName(),
+                Translations.class.getName()
+        ));
+    }
+
+    public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
+        for (TypeElement element : annotations) {
+            final Name elementName = element.getQualifiedName();
+            System.out.println("ELEMENT NAME = " + elementName);
+        }
+        return true;
+    }
+
+    public Iterable<? extends Completion> getCompletions(final Element element, final AnnotationMirror annotation, final ExecutableElement member, final String userText) {
+        return Collections.emptySet();
+    }
+}

Added: jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/LogMessage.java
===================================================================
--- jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/LogMessage.java	                        (rev 0)
+++ jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/LogMessage.java	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.i18ntool.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.jboss.logging.Logger;
+
+/**
+ * A typed logger method.  Indicates that this method will log the associated {@link Message} to the logger system, as
+ * opposed to being a simple message lookup.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Retention(RetentionPolicy.SOURCE)
+ at Target(ElementType.METHOD)
+public @interface LogMessage {
+
+    /**
+     * The log level at which this message should be logged.  Defaults to {@code INFO}.
+     *
+     * @return the log level
+     */
+    Logger.Level level() default Logger.Level.INFO;
+}

Added: jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Message.java
===================================================================
--- jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Message.java	                        (rev 0)
+++ jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Message.java	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.i18ntool.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import org.jboss.logging.ParameterConverter;
+
+/**
+ * Assigns a message string to a resource method.  The method arguments are used to supply the positional parameter
+ * values for the method.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Target(ElementType.METHOD)
+ at Retention(RetentionPolicy.SOURCE)
+public @interface Message {
+
+    /**
+     * Indicates that this message has no ID.
+     */
+    int NONE = 0;
+    /**
+     * Indicates that this message should inherit the ID from another message with the same name.
+     */
+    int INHERIT = -1;
+
+    /**
+     * The message ID number.  Only one message with a given name may specify an ID other than {@link #INHERIT}.
+     *
+     * @return the message ID number
+     */
+    int id() default INHERIT;
+
+    /**
+     * The default format string of this message.
+     *
+     * @return the format string
+     */
+    String value();
+
+    /**
+     * The format type of this method (defaults to {@link Format#PRINTF}).
+     *
+     * @return the format type
+     */
+    Format format() default Format.PRINTF;
+
+    /**
+     * The converter to use.  Any specified converter must implement {@link ParameterConverter}.
+     *
+     * @return the converter
+     */
+    Class<?> converter() default Object.class;
+
+    /**
+     * The possible format types.
+     */
+    enum Format {
+
+        /**
+         * A {@link java.util.Formatter}-type format string.
+         */
+        PRINTF,
+        /**
+         * A {@link java.text.MessageFormat}-type format string.
+         */
+        MESSAGE_FORMAT,
+    }
+
+}

Added: jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageBundle.java
===================================================================
--- jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageBundle.java	                        (rev 0)
+++ jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageBundle.java	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.i18ntool.annotation;
+
+/**
+ * Signify that an interface is a message bundle interface.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+public @interface MessageBundle {
+
+    /**
+     * Get the project code for messages that have an associated code.
+     *
+     * @return the project code
+     */
+    String projectCode() default "";
+}

Added: jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageLogger.java
===================================================================
--- jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageLogger.java	                        (rev 0)
+++ jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/MessageLogger.java	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.i18ntool.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Signify that an interface is a typed logger interface.  A message logger interface may optionally extend other message logger
+ * interfaces and message bundle interfaces (see {@link MessageBundle}, as well as the {@link org.jboss.logging.BasicLogger} interface.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Retention(RetentionPolicy.SOURCE)
+ at Target(ElementType.TYPE)
+public @interface MessageLogger {
+}

Added: jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translation.java
===================================================================
--- jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translation.java	                        (rev 0)
+++ jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translation.java	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.i18ntool.annotation;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A single translation of a message.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Target({})
+ at Retention(RetentionPolicy.SOURCE)
+public @interface Translation {
+
+    /**
+     * The locale, in the form <code>"aa[_bb[_cc]]"</code> where "aa" is the language (e.g. "en"), "bb" is the country (e.g. "US"), and
+     * "cc" is the variant.
+     *
+     * @return the locale
+     */
+    String locale();
+
+    /**
+     * The translation of this message.
+     *
+     * @return the translation
+     */
+    String message();
+}

Added: jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translations.java
===================================================================
--- jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translations.java	                        (rev 0)
+++ jboss-i18ntool/trunk/src/main/java/org/jboss/i18ntool/annotation/Translations.java	2010-04-09 18:58:49 UTC (rev 4253)
@@ -0,0 +1,45 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.i18ntool.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Assigns multiple translations of a message to a method.
+ *
+ * @author <a href="mailto:david.lloyd at redhat.com">David M. Lloyd</a>
+ */
+ at Target(ElementType.METHOD)
+ at Retention(RetentionPolicy.SOURCE)
+public @interface Translations {
+
+    /**
+     * The translations.
+     *
+     * @return the translations
+     */
+    Translation[] value();
+}



More information about the jboss-svn-commits mailing list