Liferay 7.0-ce-m3

com.liferay.portal.tools.sourceformatter
Class BaseSourceProcessor

java.lang.Object
  extended by com.liferay.portal.tools.sourceformatter.BaseSourceProcessor
All Implemented Interfaces:
SourceProcessor
Direct Known Subclasses:
CSSSourceProcessor, FTLSourceProcessor, JavaSourceProcessor, JSPSourceProcessor, JSSourceProcessor, PropertiesSourceProcessor, SHSourceProcessor, SQLSourceProcessor, TLDSourceProcessor, XMLSourceProcessor

public abstract class BaseSourceProcessor
extends Object
implements SourceProcessor


Field Summary
protected static Pattern attributeNamePattern
           
protected static String BASEDIR
           
protected static Pattern emptyCollectionPattern
           
protected static FileImpl fileUtil
           
protected static Pattern languageKeyPattern
           
protected static boolean portalSource
           
protected static SAXReaderImpl saxReaderUtil
           
protected static Pattern sessionKeyPattern
           
protected static SourceFormatterHelper sourceFormatterHelper
           
protected static Pattern taglibSessionKeyPattern
           
 
Constructor Summary
BaseSourceProcessor()
           
 
Method Summary
protected  void checkEmptyCollection(String line, String fileName, int lineCount)
           
protected  void checkIfClauseParentheses(String ifClause, String fileName, int lineCount)
           
protected  void checkInefficientStringMethods(String line, String fileName, String absolutePath, int lineCount)
           
protected  void checkLanguageKeys(String fileName, String content, Pattern pattern)
           
protected  void checkStringBundler(String line, String fileName, int lineCount)
           
protected abstract  String doFormat(File file, String fileName, String absolutePath, String content)
           
protected  String fixCompatClassImports(String absolutePath, String content)
           
protected  String fixCopyright(String content, String absolutePath, String fileName)
           
protected  String fixIncorrectParameterTypeForLanguageUtil(String content, boolean autoFix, String fileName)
           
protected  String fixSessionKey(String fileName, String content, Pattern pattern)
           
protected abstract  void format()
           
 void format(boolean useProperties, boolean printErrors, boolean autoFix)
           
protected  String format(File file, String fileName, String absolutePath, String content)
           
protected  String format(String fileName)
           
 String format(String fileName, boolean useProperties, boolean printErrors, boolean autoFix)
           
protected  String formatJavaTerms(String javaClassName, String packagePath, File file, String fileName, String absolutePath, String content, String javaClassContent, int javaClassLineCount, List<String> checkJavaFieldTypesExclusions, List<String> javaTermAccessLevelModifierExclusions, List<String> javaTermSortExclusions, List<String> testAnnotationsExclusions)
           
protected  String formatTagAttributeType(String line, String tag, String attributeAndValue)
           
protected  String getAbsolutePath(File file)
           
protected  Set<String> getAnnotationsExclusions()
           
protected  Map<String,String> getCompatClassNamesMap()
           
protected  String getContent(String fileName, int level)
           
protected  String getCustomCopyright(String absolutePath)
           
 List<String> getErrorMessages()
           
protected  File getFile(String fileName, int level)
           
protected  List<String> getFileNames(String[] excludes, String[] includes)
           
protected  List<String> getFileNames(String basedir, String[] excludes, String[] includes)
           
 SourceMismatchException getFirstSourceMismatchException()
           
protected  Set<String> getImmutableFieldTypes()
           
protected  String[] getLanguageKeys(Matcher matcher)
           
protected  Properties getLanguageProperties(String fileName)
           
protected  String getMainReleaseVersion()
           
protected  String getProperty(String key)
           
protected  List<String> getPropertyList(String key)
           
protected  boolean hasMissingParentheses(String s)
           
protected  boolean hasRedundantParentheses(String s)
           
protected  boolean hasRedundantParentheses(String s, String operator1, String operator2)
           
protected  boolean isAttributName(String attributeName)
           
protected static boolean isExcluded(List<String> exclusions, String absolutePath)
           
protected static boolean isExcluded(List<String> exclusions, String absolutePath, int lineCount)
           
protected static boolean isExcluded(List<String> exclusions, String absolutePath, int lineCount, String javaTermName)
           
protected  boolean isRunsOutsidePortal(String absolutePath)
           
protected static void processErrorMessage(String fileName, String message)
           
protected  void processFormattedFile(File file, String fileName, String content, String newContent)
           
protected  String replacePrimitiveWrapperInstantiation(String fileName, String line, int lineCount)
           
protected  String sortAttributes(String fileName, String line, int lineCount, boolean allowApostropheDelimeter)
           
protected  String stripLine(String s, char startDelimeter, char endDelimeter)
           
protected  String stripQuotes(String s, char delimeter)
           
protected  String stripRedundantParentheses(String s)
           
protected  String trimContent(String content, boolean allowLeadingSpaces)
           
protected  String trimLine(String line, boolean allowLeadingSpaces)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BASEDIR

protected static final String BASEDIR
See Also:
Constant Field Values

attributeNamePattern

protected static Pattern attributeNamePattern

emptyCollectionPattern

protected static Pattern emptyCollectionPattern

fileUtil

protected static FileImpl fileUtil

languageKeyPattern

protected static Pattern languageKeyPattern

portalSource

protected static boolean portalSource

saxReaderUtil

protected static SAXReaderImpl saxReaderUtil

sessionKeyPattern

protected static Pattern sessionKeyPattern

sourceFormatterHelper

protected static SourceFormatterHelper sourceFormatterHelper

taglibSessionKeyPattern

protected static Pattern taglibSessionKeyPattern
Constructor Detail

BaseSourceProcessor

public BaseSourceProcessor()
Method Detail

format

public void format(boolean useProperties,
                   boolean printErrors,
                   boolean autoFix)
            throws Exception
Specified by:
format in interface SourceProcessor
Throws:
Exception

format

public String format(String fileName,
                     boolean useProperties,
                     boolean printErrors,
                     boolean autoFix)
              throws Exception
Specified by:
format in interface SourceProcessor
Throws:
Exception

getErrorMessages

public List<String> getErrorMessages()
Specified by:
getErrorMessages in interface SourceProcessor

getFirstSourceMismatchException

public SourceMismatchException getFirstSourceMismatchException()
Specified by:
getFirstSourceMismatchException in interface SourceProcessor

isExcluded

protected static boolean isExcluded(List<String> exclusions,
                                    String absolutePath)

isExcluded

protected static boolean isExcluded(List<String> exclusions,
                                    String absolutePath,
                                    int lineCount)

isExcluded

protected static boolean isExcluded(List<String> exclusions,
                                    String absolutePath,
                                    int lineCount,
                                    String javaTermName)

processErrorMessage

protected static void processErrorMessage(String fileName,
                                          String message)

checkEmptyCollection

protected void checkEmptyCollection(String line,
                                    String fileName,
                                    int lineCount)

checkIfClauseParentheses

protected void checkIfClauseParentheses(String ifClause,
                                        String fileName,
                                        int lineCount)

checkInefficientStringMethods

protected void checkInefficientStringMethods(String line,
                                             String fileName,
                                             String absolutePath,
                                             int lineCount)

checkLanguageKeys

protected void checkLanguageKeys(String fileName,
                                 String content,
                                 Pattern pattern)
                          throws IOException
Throws:
IOException

checkStringBundler

protected void checkStringBundler(String line,
                                  String fileName,
                                  int lineCount)

doFormat

protected abstract String doFormat(File file,
                                   String fileName,
                                   String absolutePath,
                                   String content)
                            throws Exception
Throws:
Exception

fixCompatClassImports

protected String fixCompatClassImports(String absolutePath,
                                       String content)
                                throws IOException
Throws:
IOException

fixCopyright

protected String fixCopyright(String content,
                              String absolutePath,
                              String fileName)
                       throws IOException
Throws:
IOException

fixIncorrectParameterTypeForLanguageUtil

protected String fixIncorrectParameterTypeForLanguageUtil(String content,
                                                          boolean autoFix,
                                                          String fileName)

fixSessionKey

protected String fixSessionKey(String fileName,
                               String content,
                               Pattern pattern)

format

protected abstract void format()
                        throws Exception
Throws:
Exception

format

protected String format(File file,
                        String fileName,
                        String absolutePath,
                        String content)
                 throws Exception
Throws:
Exception

format

protected String format(String fileName)
                 throws Exception
Throws:
Exception

formatJavaTerms

protected String formatJavaTerms(String javaClassName,
                                 String packagePath,
                                 File file,
                                 String fileName,
                                 String absolutePath,
                                 String content,
                                 String javaClassContent,
                                 int javaClassLineCount,
                                 List<String> checkJavaFieldTypesExclusions,
                                 List<String> javaTermAccessLevelModifierExclusions,
                                 List<String> javaTermSortExclusions,
                                 List<String> testAnnotationsExclusions)
                          throws Exception
Throws:
Exception

formatTagAttributeType

protected String formatTagAttributeType(String line,
                                        String tag,
                                        String attributeAndValue)
                                 throws Exception
Throws:
Exception

getAbsolutePath

protected String getAbsolutePath(File file)

getAnnotationsExclusions

protected Set<String> getAnnotationsExclusions()

getCompatClassNamesMap

protected Map<String,String> getCompatClassNamesMap()
                                             throws IOException
Throws:
IOException

getContent

protected String getContent(String fileName,
                            int level)
                     throws IOException
Throws:
IOException

getCustomCopyright

protected String getCustomCopyright(String absolutePath)
                             throws IOException
Throws:
IOException

getFile

protected File getFile(String fileName,
                       int level)

getFileNames

protected List<String> getFileNames(String basedir,
                                    String[] excludes,
                                    String[] includes)

getFileNames

protected List<String> getFileNames(String[] excludes,
                                    String[] includes)

getImmutableFieldTypes

protected Set<String> getImmutableFieldTypes()

getLanguageKeys

protected String[] getLanguageKeys(Matcher matcher)

getLanguageProperties

protected Properties getLanguageProperties(String fileName)

getMainReleaseVersion

protected String getMainReleaseVersion()

getProperty

protected String getProperty(String key)

getPropertyList

protected List<String> getPropertyList(String key)

hasMissingParentheses

protected boolean hasMissingParentheses(String s)

hasRedundantParentheses

protected boolean hasRedundantParentheses(String s)

hasRedundantParentheses

protected boolean hasRedundantParentheses(String s,
                                          String operator1,
                                          String operator2)

isAttributName

protected boolean isAttributName(String attributeName)

isRunsOutsidePortal

protected boolean isRunsOutsidePortal(String absolutePath)

processFormattedFile

protected void processFormattedFile(File file,
                                    String fileName,
                                    String content,
                                    String newContent)
                             throws IOException
Throws:
IOException

replacePrimitiveWrapperInstantiation

protected String replacePrimitiveWrapperInstantiation(String fileName,
                                                      String line,
                                                      int lineCount)

sortAttributes

protected String sortAttributes(String fileName,
                                String line,
                                int lineCount,
                                boolean allowApostropheDelimeter)
                         throws Exception
Throws:
Exception

stripLine

protected String stripLine(String s,
                           char startDelimeter,
                           char endDelimeter)

stripQuotes

protected String stripQuotes(String s,
                             char delimeter)

stripRedundantParentheses

protected String stripRedundantParentheses(String s)

trimContent

protected String trimContent(String content,
                             boolean allowLeadingSpaces)
                      throws IOException
Throws:
IOException

trimLine

protected String trimLine(String line,
                          boolean allowLeadingSpaces)

Liferay 7.0-ce-m3