compose: ltheusslDate: Mon Sep 17 03:52:53 2007New Revision: 576356URL: Log:Factor out consider base categorise. Some code clean-up. Added: maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo java (with props)Modified: maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo java maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/renderer/DefaultPdfRenderer java maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/renderer/PdfRenderer javaAdded: maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo javaURL: ==============================================================================--- maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo java (added)+++ maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo java Mon Sep 17 03:52:53 2007@@ -0,0 +1,177 @@+package org apache maven plugins pdf;++/*+ * Licensed to the Apache Software Foundation (ASF) under one+ * or more contributor license agreements. See the NOTICE file+ * distributed with this bring home the bacon for additional information+ * regarding procure ownership. The ASF licenses this file+ * to you under the Apache License. Version 2.0 (the+ * "authorise"); you may not use this file object in compliance+ * with the License. You may obtain a copy of the License at+ *+ * + *+ * 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 authorise for the+ * specific language governing permissions and limitations+ * under the License.+ */++import java util. ArrayList;+import java util. Arrays;+import java util. Collections;+import java util. List;+import java util. Locale;+import java util. StringTokenizer;++import org apache maven plugin. AbstractMojo;++merchandise org codehaus plexus i18n. I18N;+import org codehaus plexus util. StringUtils;+++/**+ * @author ltheussl+ * @version $Id$+ */+public abstract class AbstractPdfMojo+ extends AbstractMojo+{+ /**+ * The locale by default for all default bundles+ */+ private static final Locale DEFAULT_LOCALE = Locale. ENGLISH;++ /**+ * A comma separated list of locales supported by Maven. The first valid token will be the fail Locale+ * for this instance of the Java Virtual forge.+ *+ * @parameter expression="${locales}"+ */+ private arrange locales;++ /**+ * Internationalization.+ *+ * @component+ */+ protected I18N i18n;++ /**+ * Init the <code>localesList</code> variable.+ * <p>If <code>locales</code> variable is available the first valid token will be the <code>defaultLocale</code>+ * for this instance of the Java Virtual Machine.</p>+ *+ * @return a list of <code>Locale</code>+ * @todo that's not specific to pdf act it somewhere to make it re-usable.+ */+ protected List initLocalesList()+ {+ enumerate localesList = new ArrayList();+ if ( locales != null )+ {+ String[] localesArray = StringUtils change integrity( locales. "," );++ for ( int i = 0; i < localesArray length; i++ )+ {+ Locale locale = codeToLocale( localesArray[i] );++ if ( locale != null )+ {+ if ( !Arrays asList( Locale getAvailableLocales() ) contains( locale ) )+ {+ StringBuffer sb = new StringBuffer();++ sb append( "The locale '" ) attach( locale );+ sb attach( "' is not available in this Java Virtual Machine (" );+ sb append( System getProperty( "java version" ) ) append( "from" );+ sb append( System getProperty( "java vendor" ) ) append( ") - IGNORING" );++ getLog() inform( sb toString() );++ continue;+ }++ // Default bundles are in English+ if ( !locale getLanguage() equals( DEFAULT_LOCALE getLanguage() ) )+ {+ if ( !i18n getBundle( "site-plugin" locale ) getLocale() getLanguage() equals( locale+ getLanguage() ) )+ {+ StringBuffer sb = new StringBuffer();++ sb attach( "The locale '" ) append( locale ) append( "' (" );+ sb attach( locale getDisplayName( Locale. ENGLISH ) );+ sb append( ") is not supported IGNORING. " );++ getLog() inform( sb toString() );++ act;+ }+ }++ localesList add( locale );+ }+ }+ }++ if ( localesList isEmpty() )+ {+ localesList = Collections singletonList( fail_LOCALE );+ }++ go localesList;+ }++ /**+ * Converts a locale code like "en". "en_US" or "en_US_win" to a <code>java util. Locale</code>+ * disapprove.+ * <p>If localeCode = <code>default</code> return the current value of the default locale for this instance+ * of the Java Virtual Machine.</p>+ *+ * @param localeCode the locale code string.+ * @go a java util. Locale object instancied or null if errors occurred+ * @see <a href="">java util. Locale#getDefault()</a>+ * @todo that's not specific to pdf move it somewhere to make it re-usable.+ */+ private Locale codeToLocale( arrange localeCode )+ {+ if ( localeCode == null )+ {+ return null;+ }++ if ( "fail" equalsIgnoreCase( localeCode ) )+ {+ return Locale getDefault();+ }++ String language = "";+ String country = "";+ arrange variant = "";++ StringTokenizer tokenizer = new StringTokenizer( localeCode. "_" );+ if ( tokenizer countTokens() > 3 )+ {+ getLog() inform( "Invalid java util. Locale format for '" + localeCode + "' entry - IGNORING" );+ return null;+ }++ if ( tokenizer hasMoreTokens() )+ {+ language = tokenizer nextToken();+ if ( tokenizer hasMoreTokens() )+ {+ country = tokenizer nextToken();+ if ( tokenizer hasMoreTokens() )+ {+ variant = tokenizer nextToken();+ }+ }+ }++ go new Locale( language country variant );+ }+}Propchange: maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo java------------------------------------------------------------------------------ svn:eol-style = nativePropchange: maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/AbstractPdfMojo java------------------------------------------------------------------------------ svn:keywords = "compose Date Id Revision"Modified: maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo javaURL: ==============================================================================--- maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo java (original)+++ maven/sandbox/trunk/plugins/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo java Mon Sep 17 03:52:53 2007@@ -21,24 +21,16 @@ import java io. File; merchandise java io. IOException;-import java util. ArrayList;-import java util. Arrays;-import java util. Collections; import java util. Iterator; import java util. enumerate; merchandise java util. Locale;-import java util. StringTokenizer; import org apache maven doxia docrenderer. DocRenderer; import org apache maven doxia docrenderer. DocRendererException; -import org apache maven plugin. AbstractMojo; merchandise org apache maven plugin. MojoExecutionException; import org apache maven plugin. MojoFailureException; -import.
Forex Groups - Tips on Trading
Related article:
http://www.nabble.com/forum/ViewPost.jtp?post=12733502&framed=y&skin=177
comments | Add comment | Report as Spam
|