Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamilo Bernal2013-01-22 17:38:54 +0000
committerSami Wagiaalla2013-01-22 19:45:23 +0000
commit9ca079005d325260f87c5e01d49d01e3609a6ab6 (patch)
treefbea387731479b5d4c1bd3c6f7af40c63014cd89
parent689db7c8246c5b30fac798c812cd55d7c8cadc68 (diff)
downloadorg.eclipse.linuxtools-9ca079005d325260f87c5e01d49d01e3609a6ab6.tar.gz
org.eclipse.linuxtools-9ca079005d325260f87c5e01d49d01e3609a6ab6.tar.xz
org.eclipse.linuxtools-9ca079005d325260f87c5e01d49d01e3609a6ab6.zip
Cleanup o.e.l.systemtap.ui.ide.structures.
* NON-NLS strings. * Remove trailing whitespace. * Add braces to conditionals. * Remove unused Query class. Change-Id: Id463c036621ec18dfdcbf35b4b520f9e3bc1bda5 Reviewed-on: https://git.eclipse.org/r/9842 Reviewed-by: Sami Wagiaalla <swagiaal@redhat.com> IP-Clean: Sami Wagiaalla <swagiaal@redhat.com> Tested-by: Sami Wagiaalla <swagiaal@redhat.com>
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/Query.java177
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/StapErrorParser.java42
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java58
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetParser.java50
-rw-r--r--systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TreeSettings.java67
5 files changed, 126 insertions, 268 deletions
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/Query.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/Query.java
deleted file mode 100644
index 1e321d6771..0000000000
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/Query.java
+++ /dev/null
@@ -1,177 +0,0 @@
-package org.eclipse.linuxtools.systemtap.ui.ide.structures;
-
-import java.util.StringTokenizer;
-
-public final class Query {
-
- public String tableName;
- public String where;
- public String groupBy;
- public String orderBy;
- public String[] columnNames;
- public String[] newColumnNames;
-
- /**
- * This constructor is only used internally to set the various fields
- * to null.
- */
- private Query() {
- this.where = null;
- this.groupBy = null;
- this.orderBy = null;
- this.newColumnNames = null;
- }
-
- public Query(final String tableName, final String[] columnNames) {
- this();
- this.tableName = tableName;
- this.columnNames = columnNames;
- }
-
- public Query(final Query query) {
- tableName = query.tableName;
- columnNames = query.columnNames;
- newColumnNames = query.newColumnNames;
- where = query.where;
- groupBy = query.groupBy;
- orderBy = query.orderBy;
- }
-
- public Query(final String tableName) {
- this();
- this.tableName = tableName;
- this.columnNames = null;
- }
-
- public Query(final String tableName, final String[] columnNames,
- final String[] newColumnNames, final String where,
- final String groupBy, final String orderBy) {
- this.tableName = tableName;
- this.columnNames = columnNames;
- this.newColumnNames = newColumnNames;
- this.where = where;
- this.groupBy = groupBy;
- this.orderBy = orderBy;
- }
-
- @Override
- public String toString() {
- return buildQuery(tableName, columnNames, newColumnNames, where,
- groupBy, orderBy);
- }
-
- private String buildQuery(final String tableName, final String[] fields,
- final String[] columnNames, final String whereClauses,
- final String groupBy, final String orderBy) {
- String query = "SELECT ";
- if (fields == (null))
- query += "* ";
- else
- for (int i = 0; i < fields.length; i++) {
- query += fields[i];
- if ((columnNames != null)
- && (columnNames.length == fields.length))
- query += " AS " + columnNames[i];
- if (i != (fields.length - 1))
- query += ", ";
- }
- query += " FROM " + tableName;
- if (whereClauses != null)
- query += " WHERE " + whereClauses;
- if (groupBy != null)
- query += " GROUP BY " + groupBy;
- if (orderBy != null)
- query += " ORDER BY " + orderBy;
- return query;
- }
-
- /**
- * Turns the query into a string that can be written to a file and easily
- * recreated as a Query object.
- *
- * @return
- */
- public String toSavableQueryString() {
- String query = tableName + ":: COLS ";
- if (columnNames != null)
- for (final String element : columnNames)
- query += element + " ";
- else
- query += "*";
-
- query += ":: NEW_COLS ";
- if (columnNames != null)
- for (final String element : newColumnNames)
- query += element + " ";
- query += ":: WHERE " + where;
- query += ":: GROUP " + groupBy;
- query += ":: ORDER " + orderBy;
- return query;
- }
-
- /**
- * Creates a Query object from a string created by toSavableQueryString()
- *
- * @param query
- * The query string to be turned into a Query object.
- * @return a new Query object created by the given string.
- */
- public static Query getQueryFromString(final String query) {
- if (query == null)
- return null;
- final String[] subQuery = query.split("::");
- final Query tempQuery = new Query(subQuery[0]);
- for (int i = 1; i < subQuery.length; i++) {
- subQuery[i] = subQuery[i].trim();
- if (subQuery[i].startsWith("COLS ")) {
- String temp = subQuery[i].replace("COLS ", "");
- temp = temp.trim();
- final StringTokenizer tok = new StringTokenizer(temp);
- final String next = tok.nextToken();
- if (next.equals("null") || next.equals("*"))
- tempQuery.columnNames = null;
- else {
- tempQuery.columnNames = new String[tok.countTokens() + 1];
- tempQuery.columnNames[0] = next;
- for (int j = 1; j < tempQuery.columnNames.length; j++)
- tempQuery.columnNames[j] = tok.nextToken();
- }
- } else if (subQuery[i].startsWith("NEW_COLS ")) {
- String temp = subQuery[i].replace("NEW_COLS ", "");
- temp = temp.trim();
- final StringTokenizer tok = new StringTokenizer(temp);
- final String next = tok.nextToken();
- if (next.equals("null"))
- tempQuery.newColumnNames = null;
- else {
- tempQuery.newColumnNames = new String[tok.countTokens() + 1];
- tempQuery.newColumnNames[0] = next;
- for (int j = 1; j < tempQuery.newColumnNames.length; j++)
- tempQuery.newColumnNames[j] = tok.nextToken();
- }
- } else if (subQuery[i].startsWith("WHERE ")) {
- String temp = subQuery[i].replace("WHERE ", "");
- temp = temp.trim();
- if (temp.equals("null"))
- tempQuery.where = null;
- else
- tempQuery.where = temp;
- } else if (subQuery[i].startsWith("GROUP ")) {
- String temp = subQuery[i].replace("GROUP ", "");
- temp = temp.trim();
- if (temp.equals("null"))
- tempQuery.groupBy = null;
- else
- tempQuery.groupBy = temp;
- } else if (subQuery[i].startsWith("ORDER ")) {
- String temp = subQuery[i].replace("ORDER ", "");
- temp = temp.trim();
- if (temp.equals("null"))
- tempQuery.orderBy = null;
- else
- tempQuery.orderBy = temp;
- }
- }
- return tempQuery;
- }
-}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/StapErrorParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/StapErrorParser.java
index 351dc38e3d..ace7c18bd1 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/StapErrorParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/StapErrorParser.java
@@ -25,57 +25,59 @@ public final class StapErrorParser implements IErrorParser {
/**
* Parses the error log passed in into a table of strings.
* @param output The output from the stderr StreamGobbler.
- * @return A table of strings in the proper format to be displayed in the error log.
+ * @return A table of strings in the proper format to be displayed in the error log.
*/
public String[][] parseOutput(String output) {
String[][] sErrors = null;
ArrayList<String[]> errors = new ArrayList<String[]>();
int errorType = TYPE;
-
+
if(null != output) {
- String[] tokens = output.split("\\s");
+ String[] tokens = output.split("\\s"); //$NON-NLS-1$
String[] row = null;
-
+
for(int i=0; i<tokens.length; i++) {
- if(tokens[i].equals("error:")) {
- row = new String[] {"", "", "", ""};
+ if(tokens[i].equals("error:")) { //$NON-NLS-1$
+ row = new String[] {"", "", "", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$
errors.add(row);
- row[TYPE] = tokens[i-1] + " " + tokens[i];
+ row[TYPE] = tokens[i-1] + " " + tokens[i]; //$NON-NLS-1$
errorType = ERROR;
i++;
- } else if(tokens[i].equals("saw:")) {
+ } else if(tokens[i].equals("saw:")) { //$NON-NLS-1$
errorType = SAW;
i++;
- } else if(tokens[i].equals("at")) {
+ } else if(tokens[i].equals("at")) { //$NON-NLS-1$
errorType = LOCATION;
i++;
- } else if(tokens[i].equals("Pass")) {
+ } else if(tokens[i].equals("Pass")) { //$NON-NLS-1$
errorType = PASS;
-
+
+ }
+
+ if (null != row && errorType != PASS) {
+ row[errorType] += tokens[i] + " "; //$NON-NLS-1$
}
-
- if(null != row && errorType != PASS)
- row[errorType] += tokens[i] + " ";
}
sErrors = new String[errors.size()][4];
System.arraycopy(errors.toArray(), 0, sErrors, 0, errors.size());
-
+
for(int i=0; i<sErrors.length; i++)
sErrors[i][LOCATION] = fixLocation(sErrors[i][LOCATION]);
}
-
+
return sErrors;
}
private static String fixLocation(String loc) {
- if(loc.contains(":")) {
+ if(loc.contains(":")) { //$NON-NLS-1$
loc = loc.substring(loc.indexOf(':')+1, loc.lastIndexOf(':'));
return loc;
- } else
- return "";
+ } else {
+ return ""; //$NON-NLS-1$
+ }
}
-
+
private static final int TYPE = 0;
private static final int ERROR = 1;
private static final int SAW = 2;
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java
index a851c98026..492b46b611 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetLibrary.java
@@ -37,21 +37,22 @@ public final class TapsetLibrary {
public static TreeNode getProbes() {
return probeTree;
}
-
+
public static TreeNode getFunctions() {
return functionTree;
}
-
+
/**
* This method will attempt to get the most up-to-date information.
- * However, if the TapsetParser is running already it will quit,
+ * However, if the TapsetParser is running already it will quit,
* assuming that new information will be available soon. By registering
* a listener at that point the class can be notified when an update is
* available.
*/
public static void init() {
- if(null != stpp && stpp.isRunning())
+ if (null != stpp && stpp.isRunning()) {
return;
+ }
IPreferenceStore preferenceStore = IDEPlugin.getDefault().getPreferenceStore();
@@ -63,7 +64,7 @@ public final class TapsetLibrary {
runStapParser();
}
}
-
+
/**
* This method will create a new instance of the TapsetParser in order
* to get the information directly from the files.
@@ -78,19 +79,19 @@ public final class TapsetLibrary {
functionTree = stpp.getFunctions();
probeTree = stpp.getProbes();
}
-
+
public static boolean isFinishSuccessful(){
return stpp.isFinishSuccessful();
}
/**
- * This method will get all of the tree information from
+ * This method will get all of the tree information from
* the TreeSettings xml file.
*/
private static void readTreeFile() {
functionTree = TreeSettings.getFunctionTree();
probeTree = TreeSettings.getProbeTree();
}
-
+
/**
* This method checks to see if the tapsets have changed
* at all since the TreeSettings.xml file was created.
@@ -103,22 +104,25 @@ public final class TapsetLibrary {
String[] tapsets = p.getString(IDEPreferenceConstants.P_TAPSETS).split(File.pathSeparator);
File f = getTapsetLocation(p);
-
- if(!checkIsCurrentFolder(treesDate, f))
+
+ if (!checkIsCurrentFolder(treesDate, f)) {
return false;
-
+ }
+
if(null != tapsets) {
for(int i=0; i<tapsets.length; i++) {
f = new File(tapsets[i]);
- if(f.lastModified() > treesDate)
+ if (f.lastModified() > treesDate) {
return false;
- if(f.canRead() && !checkIsCurrentFolder(treesDate, f))
+ }
+ if (f.canRead() && !checkIsCurrentFolder(treesDate, f)) {
return false;
+ }
}
}
return true;
}
-
+
/**
* This method attempts to locate the default tapset directory.
* @param p Preference store where the tapset location might be stored
@@ -133,7 +137,7 @@ public final class TapsetLibrary {
f = new File("/usr/local/share/systemtap/tapset"); //$NON-NLS-1$
if(!f.exists()) {
InputDialog i = new InputDialog(
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
Localization.getString("TapsetBrowserView.TapsetLocation"), Localization.getString("TapsetBrowserView.WhereDefaultTapset"), "", null); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
i.open();
p.setValue(PreferenceConstants.P_ENV[2][0], i.getValue());
@@ -146,7 +150,7 @@ public final class TapsetLibrary {
IDESessionSettings.tapsetLocation = f.getAbsolutePath();
return f;
}
-
+
/**
* This method checks the provided time stap against the folders
* time stamp. This is to see if the folder may have new data in it
@@ -158,16 +162,18 @@ public final class TapsetLibrary {
File[] fs = folder.listFiles();
for(int i=0; i<fs.length; i++) {
- if(fs[i].lastModified() > time)
+ if (fs[i].lastModified() > time) {
return false;
+ }
- if(fs[i].isDirectory() && fs[i].canRead())
- if(!checkIsCurrentFolder(time, fs[i]))
- return false;
+ if (fs[i].isDirectory() && fs[i].canRead()
+ && !checkIsCurrentFolder(time, fs[i])) {
+ return false;
+ }
}
return true;
}
-
+
/**
* Adds a new listener to the TapsetParser
* @param listener the listener to be added
@@ -176,11 +182,11 @@ public final class TapsetLibrary {
public static boolean addListener(IUpdateListener listener) {
if(null == stpp)
return false;
-
+
stpp.addListener(listener);
return true;
}
-
+
/**
* Removes the provided listener from the tapsetParser.
* @param listener The listener to be removed from the tapsetParser
@@ -188,9 +194,9 @@ public final class TapsetLibrary {
public static void removeUpdateListener(IUpdateListener listener) {
stpp.removeListener(listener);
}
-
+
/**
- * This class handles saving the results of the TapsetParser to
+ * This class handles saving the results of the TapsetParser to
* the TreeSettings.xml file.
*/
private static final IUpdateListener completionListener = new IUpdateListener() {
@@ -225,7 +231,7 @@ public final class TapsetLibrary {
/**
* This method will stop services started by
- * {@link TapsetLibrary#init()} such as the {@link TapsetParser}
+ * {@link TapsetLibrary#init()} such as the {@link TapsetParser}
* @since 1.2
*/
public static void stop(){
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetParser.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetParser.java
index 910c4f5ae6..94aa0b46b3 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetParser.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TapsetParser.java
@@ -66,8 +66,8 @@ public class TapsetParser implements Runnable {
*/
protected void init() {
disposed = false;
- functions = new TreeNode("", false);
- probes = new TreeNode("", false);
+ functions = new TreeNode("", false); //$NON-NLS-1$
+ probes = new TreeNode("", false); //$NON-NLS-1$
}
/**
@@ -77,7 +77,7 @@ public class TapsetParser implements Runnable {
public void start() {
stopped = false;
init();
- this.thread = new Thread(this, "TapsetParser");
+ this.thread = new Thread(this, "TapsetParser"); //$NON-NLS-1$
thread.start();
}
@@ -162,8 +162,9 @@ public class TapsetParser implements Runnable {
* @param listener The listener that will receive updateEvents
*/
public void addListener(IUpdateListener listener) {
- if(null != listener)
+ if (null != listener) {
listeners.add(listener);
+ }
}
/**
@@ -171,8 +172,9 @@ public class TapsetParser implements Runnable {
* @param listener The listener that no longer wants to recieve update events
*/
public void removeListener(IUpdateListener listener) {
- if(null != listener)
+ if (null != listener) {
listeners.remove(listener);
+ }
}
/**
@@ -193,15 +195,17 @@ public class TapsetParser implements Runnable {
String[] args = null;
int size = 2; //start at 2 for stap, script, options will be added in later
- if(null != tapsets && tapsets.length > 0 && tapsets[0].trim().length() > 0)
+ if (null != tapsets && tapsets.length > 0 && tapsets[0].trim().length() > 0) {
size += tapsets.length<<1;
- if(null != options && options.length > 0 && options[0].trim().length() > 0)
+ }
+ if (null != options && options.length > 0 && options[0].trim().length() > 0) {
size += options.length;
+ }
args = new String[size];
args[0] = ""; //$NON-NLS-1$
args[size-1] = probe;
- args[size-2] = "";
+ args[size-2] = ""; //$NON-NLS-1$
//Add extra tapset directories
if(null != tapsets && tapsets.length > 0 && tapsets[0].trim().length() > 0) {
@@ -219,10 +223,11 @@ public class TapsetParser implements Runnable {
StringOutputStream strErr = new StringOutputStream();
try {
URI uri;
- if(IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES))
+ if (IDEPlugin.getDefault().getPreferenceStore().getBoolean(IDEPreferenceConstants.P_REMOTE_PROBES)) {
uri = IDEPlugin.getDefault().createRemoteUri(null);
- else
+ } else {
uri = new URI(Path.ROOT.toOSString());
+ }
IRemoteCommandLauncher launcher = RemoteProxyManager.getInstance().getLauncher(uri);
Process process = launcher.execute(new Path("stap"), args, null, null, null); //$NON-NLS-1$
if(process == null){
@@ -249,8 +254,8 @@ public class TapsetParser implements Runnable {
private String readPass1(String script) {
String[] options;
if(null == script) {
- script = "**";
- options = new String[] {"-p1", "-v", "-L"};
+ script = "**"; //$NON-NLS-1$
+ options = new String[] {"-p1", "-v", "-L"}; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
} else {
options = null;
}
@@ -283,8 +288,9 @@ public class TapsetParser implements Runnable {
// If the token starts with '_' or '__' it is a private probe so
// skip it.
- if (tokenString.startsWith("_")) //$NON-NLS-1$
- continue;
+ if (tokenString.startsWith("_")) { //$NON-NLS-1$
+ continue;
+ }
int firstDotIndex = tokenString.indexOf('.');
String groupName = tokenString;
@@ -345,21 +351,21 @@ public class TapsetParser implements Runnable {
private void runPass2Functions() {
int i = 0;
TreeNode parent;
- String script = "probe begin{}";
- String result = runStap(new String[] {"-v", "-p1", "-e"}, script);
- StringTokenizer st = new StringTokenizer(result, "\n", false);
+ String script = "probe begin{}"; //$NON-NLS-1$
+ String result = runStap(new String[] {"-v", "-p1", "-e"}, script); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
+ StringTokenizer st = new StringTokenizer(result, "\n", false); //$NON-NLS-1$
st.nextToken(); //skip that stap command
- String tok = "";
+ String tok = ""; //$NON-NLS-1$
while(st.hasMoreTokens()) {
tok = st.nextToken().toString();
- String regex = "^function .*\\)\n$"; //match ^function and ending the line with ')'
+ String regex = "^function .*\\)\n$"; //match ^function and ending the line with ')' //$NON-NLS-1$
Pattern p = Pattern.compile(regex, Pattern.MULTILINE | Pattern.UNIX_LINES | Pattern.COMMENTS);
Matcher m = p.matcher(tok);
while(m.find()) {
// this gives us function foo (bar, bar)
// we need to strip the ^function and functions with a leading _
- Pattern secondp = Pattern.compile("[\\W]"); //take our function line and split it up
- Pattern underscorep = Pattern.compile("^function _.*"); //remove any lines that "^function _"
+ Pattern secondp = Pattern.compile("[\\W]"); //take our function line and split it up //$NON-NLS-1$
+ Pattern underscorep = Pattern.compile("^function _.*"); //remove any lines that "^function _" //$NON-NLS-1$
String[] us = underscorep.split(m.group().toString());
for(String s : us) {
@@ -374,7 +380,7 @@ public class TapsetParser implements Runnable {
}
else if(i > 1 && t.length() >= 1) {
parent = functions.getChildAt(functions.getChildCount()-1);
- parent.add(new TreeDefinitionNode("function " + t, t, parent.getData().toString(), false));
+ parent.add(new TreeDefinitionNode("function " + t, t, parent.getData().toString(), false)); //$NON-NLS-1$
}
i++;
}
diff --git a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TreeSettings.java b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TreeSettings.java
index b5d3dc25ac..a16ab42bcd 100644
--- a/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TreeSettings.java
+++ b/systemtap/org.eclipse.linuxtools.systemtap.ui.ide/src/org/eclipse/linuxtools/systemtap/ui/ide/structures/TreeSettings.java
@@ -42,7 +42,9 @@ public final class TreeSettings {
* @return The datestamp for the Tree file.
*/
public static long getTreeFileDate() {
- if(!readData()) return -1;
+ if (!readData()) {
+ return -1;
+ }
return treeFileDate;
}
@@ -52,7 +54,9 @@ public final class TreeSettings {
* @return The <code>TreeNode</code> root of the Function tree.
*/
public static TreeNode getFunctionTree() {
- if(!readData()) return null;
+ if (!readData()) {
+ return null;
+ }
return functions;
}
@@ -62,7 +66,9 @@ public final class TreeSettings {
* @return The <code>TreeNode</code> root of the Probe Alias tree.
*/
public static TreeNode getProbeTree() {
- if(!readData()) return null;
+ if (!readData()) {
+ return null;
+ }
return probes;
}
@@ -73,7 +79,9 @@ public final class TreeSettings {
* @return True if the caching is successful.
*/
public static boolean setTrees(TreeNode func, TreeNode probe) {
- if(null == func || null == probe) return false;
+ if (null == func || null == probe) {
+ return false;
+ }
functions = func;
probes = probe;
return writeData();
@@ -84,8 +92,9 @@ public final class TreeSettings {
* @return True if the read is successful.
*/
private static boolean readData() {
- if(null == settingsFile && !openFile())
+ if (null == settingsFile && !openFile()) {
return false;
+ }
try {
FileReader reader = new FileReader(settingsFile);
@@ -99,22 +108,26 @@ public final class TreeSettings {
IMemento child = data.getChild("functionTree"); //$NON-NLS-1$
String s = child.getString("string"); //$NON-NLS-1$
- if("<null>".equals(s)) //$NON-NLS-1$
+ if ("<null>".equals(s)) { //$NON-NLS-1$
s = null;
+ }
String d = child.getString("data"); //$NON-NLS-1$
- if("<null>".equals(d)) //$NON-NLS-1$
+ if ("<null>".equals(d)) { //$NON-NLS-1$
d = null;
+ }
functions = new TreeNode(d, s, false);
readTree(child, functions, 0);
child = data.getChild("probeTree"); //$NON-NLS-1$
s = child.getString("string"); //$NON-NLS-1$
- if("<null>".equals(s)) //$NON-NLS-1$
+ if ("<null>".equals(s)) { //$NON-NLS-1$
s = null;
+ }
d = child.getString("data"); //$NON-NLS-1$
- if("<null>".equals(d)) //$NON-NLS-1$
+ if ("<null>".equals(d)) { //$NON-NLS-1$
d = null;
+ }
probes = new TreeNode(d, s, false);
readTree(child, probes, 0);
@@ -136,8 +149,9 @@ public final class TreeSettings {
* @return True if the write is successful.
*/
private static boolean writeData() {
- if(null == settingsFile && !openFile())
+ if (null == settingsFile && !openFile()) {
return false;
+ }
try {
XMLMemento data = XMLMemento.createWriteRoot("TreeSettings"); //$NON-NLS-1$
@@ -169,21 +183,25 @@ public final class TreeSettings {
* @param depth The maximum depth level to write out.
*/
private static void writeTree(IMemento child, TreeNode tree, int depth) {
- if(null == tree.toString())
+ if (null == tree.toString()) {
child.putString("string", "<null>"); //$NON-NLS-1$ //$NON-NLS-2$
- else
+ } else {
child.putString("string", tree.toString()); //$NON-NLS-1$
+ }
- if(null == tree.getData())
- child.putString("data","<null>"); //$NON-NLS-1$ //$NON-NLS-2$
- else
+ if (null == tree.getData()) {
+ child.putString("data", "<null>"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
child.putString("data", tree.getData().toString()); //$NON-NLS-1$
+ }
- if(tree instanceof TreeDefinitionNode) {
- if(null == ((TreeDefinitionNode)tree).getDefinition())
- child.putString("definition","<null>"); //$NON-NLS-1$ //$NON-NLS-2$
- else
- child.putString("definition", ((TreeDefinitionNode)tree).getDefinition().toString()); //$NON-NLS-1$
+ if (tree instanceof TreeDefinitionNode) {
+ if (null == ((TreeDefinitionNode) tree).getDefinition()) {
+ child.putString("definition", "<null>"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ child.putString(
+ "definition", ((TreeDefinitionNode) tree).getDefinition().toString()); //$NON-NLS-1$
+ }
}
child.putInteger("click", (tree.isClickable()?1:0)); //$NON-NLS-1$
@@ -211,17 +229,20 @@ public final class TreeSettings {
boolean c = ((0==children[i].getInteger("click").intValue())?false:true); //$NON-NLS-1$
- if("<null>".equals(s)) //$NON-NLS-1$
+ if ("<null>".equals(s)) { //$NON-NLS-1$
s = null;
- if("<null>".equals(d)) //$NON-NLS-1$
+ }
+ if ("<null>".equals(d)) { //$NON-NLS-1$
d = null;
+ }
TreeNode t;
if(null == def) {
t = new TreeNode(d, s, c);
} else {
- if("<null>".equals(def)) //$NON-NLS-1$
+ if ("<null>".equals(def)) { //$NON-NLS-1$
def = null;
+ }
t = new TreeDefinitionNode(d, s, def, c);
}

Back to the top