org.nuiton.i18n.plugin.parser
Class AbstractI18nParserMojo

java.lang.Object
  extended by org.apache.maven.plugin.AbstractMojo
      extended by org.nuiton.plugin.AbstractPlugin
          extended by org.nuiton.i18n.plugin.AbstractI18nMojo
              extended by org.nuiton.i18n.plugin.parser.AbstractI18nParserMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo, I18nParserConfiguration, org.nuiton.plugin.Plugin, org.nuiton.plugin.PluginWithEncoding
Direct Known Subclasses:
AbstractParserXmlMojo, ParserJavaMojo, ParserXmlMojo

public abstract class AbstractI18nParserMojo
extends AbstractI18nMojo
implements I18nParserConfiguration

Abstract implementation for parsing goal.

Author:
tchemit

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.nuiton.plugin.Plugin
org.nuiton.plugin.Plugin.InitState, org.nuiton.plugin.Plugin.Packaging
 
Field Summary
protected  boolean backupGetter
          Flag to save previous getter in a backup before doing parsing.
protected  File cp
          Build directory (used to know if files in sources are up-to-date).
protected  I18nSourceEntry[] entries
          Source entries (src+includes+excludes) to process.
protected  boolean force
          To force reparse of all sources.
protected  boolean keysModifier
          Deprecated. since 1.2, will no more used
protected  org.nuiton.io.SortedProperties oldLanguage
           
protected  org.nuiton.io.SortedProperties oldParser
           
protected  boolean showTouchedFiles
          Flag to display touched files while parsing.
protected  long t0
           
protected  boolean treateDefaultEntry
          To treate default entry offered by the mojo.
 
Fields inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
artifactId, bundles, encoding, genSrc, locales, out, project, silent, src, strictMode, verbose
 
Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
 
Constructor Summary
AbstractI18nParserMojo()
           
 
Method Summary
protected  void addDefaultEntry()
          Add the default entry to entries given in configuration.
protected  void doAction()
           
protected abstract  File getDefaultBasedir()
           
protected abstract  String[] getDefaultExcludes()
           
protected abstract  String[] getDefaultIncludes()
           
protected abstract  String getKeyModifierEnd()
          Deprecated. since 1.2, no more used, incompatible with multi-threading parsing
protected abstract  String getKeyModifierStart()
          Deprecated. since 1.2, no more used, incompatible with multi-threading parsing
static String getLogEntry(String msg, int nbFiles, long time, long all)
          Construit une chaine de log formatée.
protected abstract  String getOutGetter()
           
 org.nuiton.io.SortedProperties getResult()
           
 void init()
           
 boolean isForce()
           
 boolean isShowTouchedFiles()
           
 boolean isStrictMode()
           
abstract  FileParser newFileParser()
           
abstract  org.nuiton.io.FileUpdater newFileUpdater(SourceEntry entry)
           
protected  boolean onEnterEntry(I18nSourceEntry entry)
           
protected  void saveGetterFile()
          Save the result in the getter file.
 
Methods inherited from class org.nuiton.i18n.plugin.AbstractI18nMojo
addGetter, backupFile, checkBundle, checkPackaging, getArtifactId, getBackupFile, getEncoding, getGetterFile, getI18nFile, getProject, isSilent, isVerbose, needGeneration, setEncoding, setProject, setVerbose
 
Methods inherited from class org.nuiton.plugin.AbstractPlugin
acceptPackaging, addCompileSourceRoots, addDirectoryToUrlsList, addResourceDir, addTestCompileSourceRoots, addTestResourceDir, addUrlToUrlsList, afterExecute, checkEncoding, checkResource, checkRunOnceDone, checkSkip, copyFile, createDirectoryIfNecessary, createNewFile, deleteFile, execute, getFileFromBasedir, getFilesToTreate, getFilesToTreateForRoots, getRootProject, getTemplate, hasClassPath, initClassLoader, isExecutionRoot, isFileNewerThanPomFile, rejectPackaging, removeCompileSourceRoots, removeTestCompileSourceRoots, renameFile, writeFile
 
Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.nuiton.i18n.plugin.parser.I18nParserConfiguration
getLog, isSilent, isVerbose
 
Methods inherited from interface org.apache.maven.plugin.Mojo
execute, getLog, setLog
 

Field Detail

cp

protected File cp
Build directory (used to know if files in sources are up-to-date).

Is defined by:
expression:
${i18n.cp}
default-value:
${basedir}/target/classes

keysModifier

@Deprecated
protected boolean keysModifier
Deprecated. since 1.2, will no more used
To activate the modification of keys

Note : By default not active, since it requires to have UI available and this is not acceptable for server build.

Note : At the moment the fully fonctionnality is no more available and will be recode in a separated goal (one day...)

Is defined by:
expression:
${i18n.keysModifier}
default-value:
false

treateDefaultEntry

protected boolean treateDefaultEntry
To treate default entry offered by the mojo.

Is defined by:
expression:
${i18n.treateDefaultEntry}
default-value:
true

entries

protected I18nSourceEntry[] entries
Source entries (src+includes+excludes) to process.

Is defined by:
expression:
${i18n.entries}

showTouchedFiles

protected boolean showTouchedFiles
Flag to display touched files while parsing.

Note: the value will be always true if AbstractI18nMojo.verbose is set at true.

Since:
0.9
Is defined by:
expression:
${i18n.showTouchedFiles}
default-value:
${maven.verbose}

backupGetter

protected boolean backupGetter
Flag to save previous getter in a backup before doing parsing.

Note: by default, do not perform backup (but it was here originaly so let it possible...)

Since:
1.0.2
Is defined by:
expression:
${i18n.backupGetter}
default-value:
false

force

protected boolean force
To force reparse of all sources.

Since:
1.2
Is defined by:
expression:
${i18n.force}
default-value:
false

oldParser

protected org.nuiton.io.SortedProperties oldParser

oldLanguage

protected org.nuiton.io.SortedProperties oldLanguage

t0

protected long t0
Constructor Detail

AbstractI18nParserMojo

public AbstractI18nParserMojo()
Method Detail

getOutGetter

protected abstract String getOutGetter()
Returns:
the outGetter to use for the instance (java.getter,...)

getKeyModifierStart

@Deprecated
protected abstract String getKeyModifierStart()
Deprecated. since 1.2, no more used, incompatible with multi-threading parsing

Returns:
the starting regex expression to catch keys in key modifier

getKeyModifierEnd

@Deprecated
protected abstract String getKeyModifierEnd()
Deprecated. since 1.2, no more used, incompatible with multi-threading parsing

Returns:
the ending regex expression to catch keys in key modifier

getDefaultIncludes

protected abstract String[] getDefaultIncludes()
Returns:
the default includes to add to directory scanner

getDefaultExcludes

protected abstract String[] getDefaultExcludes()
Returns:
the default excludes to add to directory scanner

getDefaultBasedir

protected abstract File getDefaultBasedir()
Returns:
the default src directory to use in directory scanner

newFileParser

public abstract FileParser newFileParser()
Returns:
a new file parser to be used in the parser consumer parserExecutor
Since:
1.2

newFileUpdater

public abstract org.nuiton.io.FileUpdater newFileUpdater(SourceEntry entry)
Parameters:
entry - the incoming source entry to attach to the file updater
Returns:
a new file updater to detects files to treate

isStrictMode

public boolean isStrictMode()
Overrides:
isStrictMode in class AbstractI18nMojo

isForce

public boolean isForce()

init

public void init()
          throws Exception
Overrides:
init in class AbstractI18nMojo
Throws:
Exception

onEnterEntry

protected boolean onEnterEntry(I18nSourceEntry entry)

doAction

protected void doAction()
                 throws Exception
Specified by:
doAction in class org.nuiton.plugin.AbstractPlugin
Throws:
Exception

isShowTouchedFiles

public boolean isShowTouchedFiles()
Specified by:
isShowTouchedFiles in interface I18nParserConfiguration

getResult

public org.nuiton.io.SortedProperties getResult()
Specified by:
getResult in interface I18nParserConfiguration

addDefaultEntry

protected void addDefaultEntry()
Add the default entry to entries given in configuration.

This is a convinient method to simplify the configuration of the plugin.


saveGetterFile

protected void saveGetterFile()
                       throws IOException
Save the result in the getter file.

Throws:
IOException - if any io pb

getLogEntry

public static String getLogEntry(String msg,
                                 int nbFiles,
                                 long time,
                                 long all)
Construit une chaine de log formatée.

Parameters:
msg - le prefix du message
nbFiles - le nombre de fichiers actuellement traités
time - le time de traitement de ce fichier
all - le temps de traitement de tous les fichiers
Returns:
la chaine de log formatée


Copyright © 2007-2010 CodeLutin. All Rights Reserved.