diff --git a/src/main/java/net/vhati/modmanager/core/ModUtilities.java b/src/main/java/net/vhati/modmanager/core/ModUtilities.java
index 25b038b..2cf342a 100644
--- a/src/main/java/net/vhati/modmanager/core/ModUtilities.java
+++ b/src/main/java/net/vhati/modmanager/core/ModUtilities.java
@@ -185,10 +185,10 @@ public class ModUtilities {
Pattern xmlDeclPtn = Pattern.compile( "<[?]xml [^>]*?[?]>\n*" );
String mainText = decodeText( mainStream, mainDescription ).text;
- mainText = xmlDeclPtn.matcher(mainText).replaceFirst( "" );
+ mainText = xmlDeclPtn.matcher( mainText ).replaceFirst( "" );
String appendText = decodeText( appendStream, appendDescription ).text;
- appendText = xmlDeclPtn.matcher(appendText).replaceFirst( "" );
+ appendText = xmlDeclPtn.matcher( appendText ).replaceFirst( "" );
// Concatenate, filtering the stream to standardize newlines and encode.
//
@@ -230,13 +230,13 @@ public class ModUtilities {
Pattern xmlDeclPtn = Pattern.compile( "<[?]xml [^>]*?[?]>\n*" );
String mainText = decodeText( mainStream, mainDescription ).text;
- mainText = xmlDeclPtn.matcher(mainText).replaceFirst( "" );
+ mainText = xmlDeclPtn.matcher( mainText ).replaceFirst( "" );
mainText = ""+ mainText +"";
Document mainDoc = parseStrictOrSloppyXML( mainText, mainDescription+" (wrapped)" );
mainText = null;
String appendText = decodeText( appendStream, appendDescription ).text;
- appendText = xmlDeclPtn.matcher(appendText).replaceFirst( "" );
+ appendText = xmlDeclPtn.matcher( appendText ).replaceFirst( "" );
appendText = ""+ appendText +"";
Document appendDoc = parseStrictOrSloppyXML( appendText, appendDescription+" (wrapped)" );
appendText = null;
@@ -282,7 +282,7 @@ public class ModUtilities {
Pattern xmlDeclPtn = Pattern.compile( "<[?]xml [^>]*?[?]>\n*" );
String srcText = decodeText( srcStream, srcDescription ).text;
- srcText = xmlDeclPtn.matcher(srcText).replaceFirst( "" );
+ srcText = xmlDeclPtn.matcher( srcText ).replaceFirst( "" );
srcText = ""+ srcText +"";
Document doc = parseStrictOrSloppyXML( srcText, srcDescription+" (wrapped)" );
srcText = null;
@@ -350,7 +350,7 @@ public class ModUtilities {
* @param innerPath a path with forward slashes
*/
public static boolean isJunkFile( String innerPath ) {
- return junkFilePtn.matcher(innerPath).find();
+ return junkFilePtn.matcher( innerPath ).find();
}
@@ -369,7 +369,7 @@ public class ModUtilities {
Pattern validRootDirPtn = Pattern.compile( "^(?:audio|data|fonts|img|mod-appendix)/" );
List seenJunkDirs = new ArrayList();
- CharsetEncoder asciiEncoder = Charset.forName("US-ASCII").newEncoder();
+ CharsetEncoder asciiEncoder = Charset.forName( "US-ASCII" ).newEncoder();
ZipInputStream zis = null;
try {
@@ -396,14 +396,14 @@ public class ModUtilities {
modValid = false;
}
- if ( innerPath.indexOf("/") == -1 ) {
+ if ( innerPath.indexOf( "/" ) == -1 ) {
pendingMsgs.add( new ReportMessage(
ReportMessage.WARNING,
String.format( "Extraneous top-level file." )
) );
modValid = false;
}
- else if ( !validRootDirPtn.matcher(innerPath).find() ) {
+ else if ( !validRootDirPtn.matcher( innerPath ).find() ) {
String junkDir = innerPath.replaceFirst( "/.*", "/" );
if ( !seenJunkDirs.contains( junkDir ) ) {
seenJunkDirs.add( junkDir );
@@ -516,16 +516,16 @@ public class ModUtilities {
Map> oddCharLists = new HashMap>();
oddCharPtns.add( Pattern.compile( "\\u0060|\\u201A|\\u2018|\\u2019" ) );
- oddCharSuggestions.put( oddCharPtns.get(oddCharPtns.size()-1), "'" );
+ oddCharSuggestions.put( oddCharPtns.get( oddCharPtns.size()-1 ), "'" );
oddCharPtns.add( Pattern.compile( "\\u201E|\\u201C|\\u201D" ) );
- oddCharSuggestions.put( oddCharPtns.get(oddCharPtns.size()-1), "\"" );
+ oddCharSuggestions.put( oddCharPtns.get( oddCharPtns.size()-1 ), "\"" );
oddCharPtns.add( Pattern.compile( "\\u2013|\\u2014" ) );
- oddCharSuggestions.put( oddCharPtns.get(oddCharPtns.size()-1), "-" );
+ oddCharSuggestions.put( oddCharPtns.get( oddCharPtns.size()-1 ), "-" );
oddCharPtns.add( Pattern.compile( "\\u2026" ) );
- oddCharSuggestions.put( oddCharPtns.get(oddCharPtns.size()-1), "..." );
+ oddCharSuggestions.put( oddCharPtns.get( oddCharPtns.size()-1 ), "..." );
for ( Pattern ptn : oddCharPtns ) {
Matcher m = ptn.matcher( decodeResult.text );
@@ -534,7 +534,7 @@ public class ModUtilities {
if ( chars == null )
chars = new ArrayList();
- Character cObj = new Character( m.group(0).charAt(0) );
+ Character cObj = new Character( m.group( 0 ).charAt( 0 ) );
if ( !chars.contains( cObj ) )
chars.add( cObj );
}
@@ -693,36 +693,36 @@ public class ModUtilities {
if ( !foundTopDecl )
dstBuf.insert( 0, Matcher.quoteReplacement( wrapperSTag ) );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// Comments with long tails or double-dashes.
m = Pattern.compile( "(?s)" ).matcher( srcBuf );
while ( m.find() ) {
- if ( m.group(1).length() > 0 || m.group(3).length() > 0 || m.group(2).indexOf("--") != -1 ) {
+ if ( m.group( 1 ).length() > 0 || m.group( 3 ).length() > 0 || m.group( 2 ).indexOf( "--" ) != -1 ) {
messages.add( new ReportMessage(
ReportMessage.ERROR,
""
) );
}
- m.appendReplacement( dstBuf, m.quoteReplacement(m.group(2).replaceAll("[^\n]", "")) ); // Strip comments, but preserve line count.
+ m.appendReplacement( dstBuf, m.quoteReplacement(m.group( 2 ).replaceAll( "[^\n]", "" )) ); // Strip comments, but preserve line count.
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// Mismatched single-line tags.
// Example: blueprints.xml: ...
m = Pattern.compile( "<([^/!][^> ]+?)((?: [^>]+?)?)(?([^<]+?)([^>]+?)>" ).matcher( srcBuf );
while ( m.find() ) {
- if ( m.group(1).equals( m.group(4) ) == false ) {
+ if ( m.group( 1 ).equals( m.group( 4 ) ) == false ) {
messages.add( new ReportMessage(
ReportMessage.ERROR,
- "<"+ m.group(1) +"...>..."+ m.group(4) +">"
+ "<"+ m.group( 1 ) +"...>..."+ m.group( 4 ) +">"
) );
- m.appendReplacement( dstBuf, m.quoteReplacement("<"+ m.group(1) + m.group(2) +">"+ m.group(3) +""+ m.group(1) +">") );
+ m.appendReplacement( dstBuf, m.quoteReplacement("<"+ m.group( 1 ) + m.group( 2 ) +">"+ m.group( 3 ) +""+ m.group( 1 ) +">") );
}
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
//
// Groan, \t separates attribs sometimes.
@@ -730,12 +730,12 @@ public class ModUtilities {
while ( m.find() ) {
messages.add( new ReportMessage(
ReportMessage.ERROR,
- "<"+ m.group(1) +"...\""+ m.group(3) +"...>"
+ "<"+ m.group( 1 ) +"...\""+ m.group( 3 ) +"...>"
) );
- m.appendReplacement( dstBuf, m.quoteReplacement("<"+ m.group(1) + m.group(2) +" "+ m.group(3) + m.group(4) +">") );
+ m.appendReplacement( dstBuf, m.quoteReplacement( "<"+ m.group( 1 ) + m.group( 2 ) +" "+ m.group( 3 ) + m.group( 4 ) +">" ) );
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// sector_data.xml closing tag.
m = Pattern.compile( "((?s)]*>.*?)" ).matcher( srcBuf );
@@ -747,36 +747,36 @@ public class ModUtilities {
m.appendReplacement( dstBuf, m.quoteReplacement(m.group(1) +"") );
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// {anyship}.xml: ...
m = Pattern.compile( "(?s)<(gib[0-9]+)>(.*?)(gib[0-9]+)>" ).matcher( srcBuf );
while ( m.find() ) {
- if ( m.group(1).equals( m.group(3) ) == false ) {
+ if ( m.group( 1 ).equals( m.group( 3 ) ) == false ) {
messages.add( new ReportMessage(
ReportMessage.ERROR,
- "<"+ m.group(1) +">..."+ m.group(3) +">"
+ "<"+ m.group( 1 ) +">..."+ m.group( 3 ) +">"
) );
- m.appendReplacement( dstBuf, m.quoteReplacement("<"+ m.group(1) +">"+ m.group(2) +""+ m.group(1) +">") );
+ m.appendReplacement( dstBuf, m.quoteReplacement( "<"+ m.group( 1 ) +">"+ m.group( 2 ) +""+ m.group( 1 ) +">" ) );
}
else {
- m.appendReplacement( dstBuf, m.quoteReplacement(m.group(0)) );
+ m.appendReplacement( dstBuf, m.quoteReplacement( m.group( 0 ) ) );
}
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// event*.xml:
m = Pattern.compile( "<([a-zA-Z0-9_-]+?)((?: [^>]+?)?) ([^>]+?)(=\"[^\">]+?\") \\3(?:=\"[^\">]+?\")([^>]*)>" ).matcher( srcBuf );
while ( m.find() ) {
messages.add( new ReportMessage(
ReportMessage.ERROR,
- "<"+ m.group(1) +"... "+ m.group(3) +"=... "+ m.group(3) +"=...>"
+ "<"+ m.group( 1 ) +"... "+ m.group( 3 ) +"=... "+ m.group( 3 ) +"=...>"
) );
- m.appendReplacement( dstBuf, m.quoteReplacement("<"+ m.group(1) + m.group(2) +" "+ m.group(3) + m.group(4) +" "+ m.group(5) +">") );
+ m.appendReplacement( dstBuf, m.quoteReplacement( "<"+ m.group( 1 ) + m.group( 2 ) +" "+ m.group( 3 ) + m.group( 4 ) +" "+ m.group( 5 ) +">" ) );
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// ...
ptn = "";
@@ -792,10 +792,10 @@ public class ModUtilities {
ReportMessage.ERROR,
"..."
) );
- m.appendReplacement( dstBuf, m.quoteReplacement(m.group(1) +"") );
+ m.appendReplacement( dstBuf, m.quoteReplacement( m.group( 1 ) +"" ) );
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// ...
ptn = "";
@@ -818,10 +818,10 @@ public class ModUtilities {
ReportMessage.ERROR,
"..."
) );
- m.appendReplacement( dstBuf, m.quoteReplacement(m.group(1) +"") );
+ m.appendReplacement( dstBuf, m.quoteReplacement( m.group( 1 ) +"" ) );
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
// ...
ptn = "";
@@ -834,15 +834,15 @@ public class ModUtilities {
ReportMessage.ERROR,
"..."
) );
- m.appendReplacement( dstBuf, m.quoteReplacement(m.group(1) +"") );
+ m.appendReplacement( dstBuf, m.quoteReplacement( m.group( 1 ) +"" ) );
}
m.appendTail( dstBuf );
- tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength(0);
+ tmpBuf = srcBuf; srcBuf = dstBuf; dstBuf = tmpBuf; dstBuf.setLength( 0 );
Document doc = null;
try {
SAXBuilder saxBuilder = new SAXBuilder();
- doc = saxBuilder.build( new StringReader(srcBuf.toString()) );
+ doc = saxBuilder.build( new StringReader( srcBuf.toString() ) );
xmlValid = true;
for ( ReportMessage message : messages ) {
@@ -859,7 +859,7 @@ public class ModUtilities {
int badEnd = -1;
String badLine = "???";
m = Pattern.compile( "\n|\\z" ).matcher( srcBuf );
- for ( int i=1; i <= lineNum && m.find(); i++) {
+ for ( int i=1; i <= lineNum && m.find(); i++ ) {
if ( i == lineNum-1 ) {
badStart = m.end();
} else if ( i == lineNum ) {
@@ -922,10 +922,11 @@ public class ModUtilities {
int badEnd = -1;
String badLine = "???";
Matcher m = Pattern.compile( "\n|\\z" ).matcher( text );
- for ( int i=1; i <= lineNum && m.find(); i++) {
+ for ( int i=1; i <= lineNum && m.find(); i++ ) {
if ( i == lineNum-1 ) {
badStart = m.end();
- } else if ( i == lineNum ) {
+ }
+ else if ( i == lineNum ) {
badEnd = m.start();
badLine = text.substring( badStart, badEnd );
}