java: simplify array creation

and remove the need to worry about keeping indexes correct

Change-Id: I9a5fc00f7e28f305279b41099274c96daebebb95
This commit is contained in:
Noel Grandin 2015-01-09 14:51:38 +02:00
parent 8912e6dab9
commit 3757c03fc8
16 changed files with 43 additions and 70 deletions

View File

@ -496,10 +496,9 @@ public class TypeDetection extends ComplexTestCase {
* *
*/ */
log.println("### checkStreamLoader() ###"); log.println("### checkStreamLoader() ###");
String[] urls = new String[2]; String[] urls = new String[] {
helper.getClassURLString("TypeDetection.props"),
urls[0] = helper.getClassURLString("TypeDetection.props"); helper.getClassURLString("files.csv") };
urls[1] = helper.getClassURLString("files.csv");
for (int j=0; j<urls.length; j++){ for (int j=0; j<urls.length; j++){
String fileURL = urls[j]; String fileURL = urls[j];

View File

@ -259,8 +259,7 @@ public class Interceptor implements XDispatch,
{ {
if (m_lURLs4InterceptionInfo == null) if (m_lURLs4InterceptionInfo == null)
{ {
m_lURLs4InterceptionInfo = new String[1]; m_lURLs4InterceptionInfo = new String[] { "*" };
m_lURLs4InterceptionInfo[0] = "*";
} }
return m_lURLs4InterceptionInfo; return m_lURLs4InterceptionInfo;
@ -276,8 +275,7 @@ public class Interceptor implements XDispatch,
{ {
if (m_lURLs4Blocking == null) if (m_lURLs4Blocking == null)
{ {
m_lURLs4Blocking = new String[1]; m_lURLs4Blocking = new String[] { "*" };
m_lURLs4Blocking[0] = "*";
} }
return m_lURLs4Blocking; return m_lURLs4Blocking;

View File

@ -251,8 +251,7 @@ public class checkdispatchapi
public void checkInterception() public void checkInterception()
{ {
String[] lDisabledURLs = new String[1]; String[] lDisabledURLs = new String[] { ".uno:Open" };
lDisabledURLs[0] = ".uno:Open";
System.out.println("create and initialize interceptor ..."); System.out.println("create and initialize interceptor ...");
Interceptor aInterceptor = new Interceptor(); Interceptor aInterceptor = new Interceptor();

View File

@ -270,13 +270,13 @@ public class Bootstrap {
Long.toString( (new Random()).nextLong() & 0x7fffffffffffffffL ); Long.toString( (new Random()).nextLong() & 0x7fffffffffffffffL );
// create call with arguments // create call with arguments
String[] cmdArray = new String[6]; String[] cmdArray = new String[] {
cmdArray[0] = fOffice.getPath(); fOffice.getPath(),
cmdArray[1] = "--nologo"; "--nologo",
cmdArray[2] = "--nodefault"; "--nodefault",
cmdArray[3] = "--norestore"; "--norestore",
cmdArray[4] = "--nolockcheck"; "--nolockcheck",
cmdArray[5] = "--accept=pipe,name=" + sPipeName + ";urp;"; "--accept=pipe,name=" + sPipeName + ";urp;" };
// start office process // start office process
Process p = Runtime.getRuntime().exec( cmdArray ); Process p = Runtime.getRuntime().exec( cmdArray );

View File

@ -245,9 +245,9 @@ XComponent xDoc = DesktopTools.loadDoc(xMSF, FileToLoad,
} }
private String[] getLeftAndRight(int counter, XSpreadsheet xSpreadsheet) { private String[] getLeftAndRight(int counter, XSpreadsheet xSpreadsheet) {
String[] re = new String[2]; String[] re = new String[] {
re[0] = getCell(0, counter, xSpreadsheet).getFormula().trim(); getCell(0, counter, xSpreadsheet).getFormula().trim(),
re[1] = getCell(1, counter, xSpreadsheet).getFormula().trim(); getCell(1, counter, xSpreadsheet).getFormula().trim() };
return re; return re;
} }

View File

@ -190,10 +190,10 @@ public class DialogComponent {
} }
public String[] getSupportedMethodNames() { public String[] getSupportedMethodNames() {
String[] retValue= new String[3]; String[] retValue= new String[] {
retValue[0]= aHandlerMethod1; aHandlerMethod1,
retValue[1]= aHandlerMethod2; aHandlerMethod2,
retValue[2]= aHandlerMethod3; aHandlerMethod3 };
return retValue; return retValue;
} }

View File

@ -401,10 +401,7 @@ public class ConfigExamples
UnoRuntime.queryInterface(XMultiPropertySet.class, xSubdivision); UnoRuntime.queryInterface(XMultiPropertySet.class, xSubdivision);
// variables for multi-element access // variables for multi-element access
String[] aElementNames = new String[2]; String[] aElementNames = new String[] { "XAxis", "YAxis" };
aElementNames[0] = "XAxis";
aElementNames[1] = "YAxis";
Object[] aElementValues = xSubdivProperties.getPropertyValues(aElementNames); Object[] aElementValues = xSubdivProperties.getPropertyValues(aElementNames);
@ -869,9 +866,7 @@ public class ConfigExamples
aSettings[0] = new com.sun.star.beans.NamedValue("HeaderLine",Boolean.TRUE); aSettings[0] = new com.sun.star.beans.NamedValue("HeaderLine",Boolean.TRUE);
aSettings[1] = new com.sun.star.beans.NamedValue("FieldDelimiter",";"); aSettings[1] = new com.sun.star.beans.NamedValue("FieldDelimiter",";");
String [] aTableFilter = new String[2]; String [] aTableFilter = new String[] { "table.txt", "othertable.txt" };
aTableFilter[0] = "table.txt";
aTableFilter[1] = "othertable.txt";
storeDataSource(sSampleDataSourceName,sSampleDataSourceURL,"",false,0,aSettings,aTableFilter); storeDataSource(sSampleDataSourceName,sSampleDataSourceURL,"",false,0,aSettings,aTableFilter);
} }

View File

@ -291,9 +291,7 @@ final class InstallationFinder {
String path = null; String path = null;
// start the which process // start the which process
String[] cmdArray = new String[2]; String[] cmdArray = new String[] { WHICH, SOFFICE };
cmdArray[0] = WHICH;
cmdArray[1] = SOFFICE;
Process proc = null; Process proc = null;
Runtime rt = Runtime.getRuntime(); Runtime rt = Runtime.getRuntime();
try { try {

View File

@ -67,9 +67,9 @@ public class _XMultiLayerStratum extends MultiMethodTest {
boolean res = true; boolean res = true;
try { try {
String[] LayerIds = new String[2]; String[] LayerIds = new String[] {
LayerIds[0] = "1 /org/openoffice/Office/Jobs.xcu"; "1 /org/openoffice/Office/Jobs.xcu",
LayerIds[1] = "2 /org/openoffice/Office/Linguistic.xcu"; "2 /org/openoffice/Office/Linguistic.xcu" };
XLayer[] Layers = oObj.getLayers(LayerIds, ""); XLayer[] Layers = oObj.getLayers(LayerIds, "");
res = Layers.length == 2; res = Layers.length == 2;
@ -93,12 +93,10 @@ public class _XMultiLayerStratum extends MultiMethodTest {
boolean res = true; boolean res = true;
try { try {
String[] LayerIds = new String[2]; String[] LayerIds = new String[] {
LayerIds[0] = "1 /org/openoffice/Office/Jobs.xcu"; "1 /org/openoffice/Office/Jobs.xcu",
LayerIds[1] = "2 /org/openoffice/Office/Linguistic.xcu"; "2 /org/openoffice/Office/Linguistic.xcu" };
String[] Times = new String[2]; String[] Times = new String[] { "", "" };
Times[0] = "";
Times[1] = "";
XLayer[] Layers = oObj.getMultipleLayers(LayerIds, Times); XLayer[] Layers = oObj.getMultipleLayers(LayerIds, Times);
res = Layers.length == 2; res = Layers.length == 2;

View File

@ -105,9 +105,7 @@ public class CallFormWizard
*/ */
public java.lang.String[] getSupportedServiceNames() public java.lang.String[] getSupportedServiceNames()
{ {
String[] stringSupportedServiceNames = new String[1]; String[] stringSupportedServiceNames = new String[] { __serviceName };
stringSupportedServiceNames[0] = __serviceName;
return (stringSupportedServiceNames); return (stringSupportedServiceNames);
} }

View File

@ -111,9 +111,7 @@ public class CallQueryWizard
*/ */
public java.lang.String[] getSupportedServiceNames() public java.lang.String[] getSupportedServiceNames()
{ {
String[] stringSupportedServiceNames = new String[1]; String[] stringSupportedServiceNames = new String[] { __serviceName };
stringSupportedServiceNames[0] = __serviceName;
return (stringSupportedServiceNames); return (stringSupportedServiceNames);
} }

View File

@ -137,9 +137,7 @@ public class CallReportWizard
*/ */
public java.lang.String[] getSupportedServiceNames() public java.lang.String[] getSupportedServiceNames()
{ {
String[] stringSupportedServiceNames = new String[1]; String[] stringSupportedServiceNames = new String[] { __serviceName };
stringSupportedServiceNames[ 0] = __serviceName;
return (stringSupportedServiceNames); return (stringSupportedServiceNames);
} }

View File

@ -653,10 +653,8 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
catch (com.sun.star.wizards.common.NoValidPathException e) catch (com.sun.star.wizards.common.NoValidPathException e)
{ {
ContentFiles = new String[2][]; ContentFiles = new String[2][];
String[] a = new String[1]; String[] a = new String[] { "DefaultLayoutOfData" };
String[] b = new String[1]; String[] b = new String[] { "default" };
a[0] = "DefaultLayoutOfData";
b[0] = "default";
ContentFiles[1] = a; ContentFiles[1] = a;
ContentFiles[0] = b; ContentFiles[0] = b;
} }
@ -674,10 +672,8 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
catch (com.sun.star.wizards.common.NoValidPathException e) catch (com.sun.star.wizards.common.NoValidPathException e)
{ {
LayoutFiles = new String[2][]; LayoutFiles = new String[2][];
String[] a = new String[1]; String[] a = new String[] { "DefaultLayoutOfHeaders" };
String[] b = new String[1]; String[] b = new String[] { "default" };
a[0] = "DefaultLayoutOfHeaders";
b[0] = "default";
LayoutFiles[1] = a; LayoutFiles[1] = a;
LayoutFiles[0] = b; LayoutFiles[0] = b;
} }

View File

@ -612,10 +612,8 @@ public class ReportBuilderImplementation extends ReportImplementationHelper
{ {
// if there are problems, don't show anything is a little bit hard. // if there are problems, don't show anything is a little bit hard.
LayoutFiles = new String[2][]; LayoutFiles = new String[2][];
String[] a = new String[1]; String[] a = new String[] { "DefaultLayoutOfHeaders" };
String[] b = new String[1]; String[] b = new String[] { "default" };
a[0] = "DefaultLayoutOfHeaders";
b[0] = "default";
LayoutFiles[1] = a; LayoutFiles[1] = a;
LayoutFiles[0] = b; LayoutFiles[0] = b;
} }

View File

@ -110,9 +110,7 @@ public class CallTableWizard
*/ */
public java.lang.String[] getSupportedServiceNames() public java.lang.String[] getSupportedServiceNames()
{ {
String[] stringSupportedServiceNames = new String[1]; String[] stringSupportedServiceNames = new String[] { __serviceName };
stringSupportedServiceNames[0] = __serviceName;
return (stringSupportedServiceNames); return (stringSupportedServiceNames);
} }

View File

@ -355,9 +355,9 @@ public class AggregateComponent extends ControlScroller
short[] iselfunction = (short[]) AnyConverter.toArray(currowproperties[0].Value); short[] iselfunction = (short[]) AnyConverter.toArray(currowproperties[0].Value);
if ((iselfield.length > 0) && (iselfunction.length > 0)) if ((iselfield.length > 0) && (iselfunction.length > 0))
{ {
String[] curaggregatename = new String[2]; String[] curaggregatename = new String[] {
curaggregatename[0] = CurDBMetaData.NumericFieldNames[iselfield[0]]; CurDBMetaData.NumericFieldNames[iselfield[0]],
curaggregatename[1] = this.sFunctionOperators[iselfunction[0]]; this.sFunctionOperators[iselfunction[0]] };
aggregatevector.add(curaggregatename); aggregatevector.add(curaggregatename);
} }
} }