You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2006/11/22 17:50:39 UTC

svn commit: r478233 - in /incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp: EP_LogThrowErrorImpl.java JgPlugin.java JgPluginRunner.java MergerImpl.java ProgressMonitorImpl.java

Author: alally
Date: Wed Nov 22 08:50:38 2006
New Revision: 478233

URL: http://svn.apache.org/viewvc?view=rev&rev=478233
Log:
UIMA-48: reformatted code and fixed trivial compiler warnings

Modified:
    incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/EP_LogThrowErrorImpl.java
    incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPlugin.java
    incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPluginRunner.java
    incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/MergerImpl.java
    incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/ProgressMonitorImpl.java

Modified: incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/EP_LogThrowErrorImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/EP_LogThrowErrorImpl.java?view=diff&rev=478233&r1=478232&r2=478233
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/EP_LogThrowErrorImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/EP_LogThrowErrorImpl.java Wed Nov 22 08:50:38 2006
@@ -26,25 +26,20 @@
 import org.eclipse.core.runtime.Status;
 
 public class EP_LogThrowErrorImpl implements IError {
-     
-  private static int logLevels [] = {IStatus.INFO, IStatus.WARNING, IStatus.ERROR};
 
-	/* (non-Javadoc)
-	 * @see org.apache.uima.jcas.jcasgen_gen.IError#newError(int, java.lang.String)
-	 */
-	public void newError(int severity, String message, Exception exception) {
-		String pluginId =
-			JgPlugin.getDefault().getDescriptor().getUniqueIdentifier();
-		ILog log = JgPlugin.getDefault().getLog();
-		log.log(
-			new Status(
-				logLevels[severity],
-				pluginId,
-				IStatus.OK,
-				message,
-				exception));
-		if (IError.WARN < severity)
-		  throw new ErrorExit();
-	}
-	
+  private static int logLevels[] = { IStatus.INFO, IStatus.WARNING, IStatus.ERROR };
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.apache.uima.jcas.jcasgen_gen.IError#newError(int, java.lang.String)
+   */
+  public void newError(int severity, String message, Exception exception) {
+    String pluginId = JgPlugin.getDefault().getDescriptor().getUniqueIdentifier();
+    ILog log = JgPlugin.getDefault().getLog();
+    log.log(new Status(logLevels[severity], pluginId, IStatus.OK, message, exception));
+    if (IError.WARN < severity)
+      throw new ErrorExit();
+  }
+
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPlugin.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPlugin.java?view=diff&rev=478233&r1=478232&r2=478233
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPlugin.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPlugin.java Wed Nov 22 08:50:38 2006
@@ -28,36 +28,37 @@
  * The main plugin class to be used in the desktop.
  */
 public class JgPlugin extends Plugin {
-	//The shared instance.
-	private static JgPlugin plugin;
+  // The shared instance.
+  private static JgPlugin plugin;
 
-	public static final String JCASGEN_ID = "org.apache.uima.jcas.jcasgenp"; //$NON-NLS-1$
-	
-	/**
-	 * The constructor.
-	 */
-	public JgPlugin(IPluginDescriptor descriptor) {
-		super(descriptor);
-		plugin = this;
-	}
+  public static final String JCASGEN_ID = "org.apache.uima.jcas.jcasgenp"; //$NON-NLS-1$
 
-	/**
-	 * Returns the shared instance.
-	 */
-	public static JgPlugin getDefault() {
-		return plugin;
-	}
+  /**
+   * The constructor.
+   */
+  public JgPlugin(IPluginDescriptor descriptor) {
+    super(descriptor);
+    plugin = this;
+  }
 
-	/**
-	 * Returns the workspace instance.
-	 */
-	public static IWorkspace getWorkspace() {
-		return ResourcesPlugin.getWorkspace();
-	}
-	/**
-	 * Convenience method which returns the unique identifier of this plugin.
-	 */
-	public static String getUniqueIdentifier() {
-		return JCASGEN_ID;
-	}
+  /**
+   * Returns the shared instance.
+   */
+  public static JgPlugin getDefault() {
+    return plugin;
+  }
+
+  /**
+   * Returns the workspace instance.
+   */
+  public static IWorkspace getWorkspace() {
+    return ResourcesPlugin.getWorkspace();
+  }
+
+  /**
+   * Convenience method which returns the unique identifier of this plugin.
+   */
+  public static String getUniqueIdentifier() {
+    return JCASGEN_ID;
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPluginRunner.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPluginRunner.java?view=diff&rev=478233&r1=478232&r2=478233
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPluginRunner.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/JgPluginRunner.java Wed Nov 22 08:50:38 2006
@@ -28,37 +28,34 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 
 /**
- * Class holds type plugin-wide collections and static methods.
- * Also implements the runnable that is called to do the processing
+ * Class holds type plugin-wide collections and static methods. Also implements the runnable that is
+ * called to do the processing
  */
 
 public class JgPluginRunner implements IPlatformRunnable {
 
-	public JgPluginRunner() {
-	}
+  public JgPluginRunner() {
+  }
 
-	public Object run(Object object) {
-		try {
-			final String[] arguments = (String[]) object;
-			final IWorkspace workspace = ResourcesPlugin.getWorkspace();
-			final Jg jg = new Jg();
-			IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
-				public void run(IProgressMonitor progressMonitor)
-					throws CoreException {
-						jg.main0(arguments, 
-						         new MergerImpl(), 
-										 null, // no progressMonitor, 
-										 new EP_LogThrowErrorImpl() );
-				}
-			};
-			workspace.run(runnable, null);
-			return new Integer(0);
-		} catch (Exception exception) {
-			exception.printStackTrace();
-		}
-		
-		return new Integer(1);
+  public Object run(Object object) {
+    try {
+      final String[] arguments = (String[]) object;
+      final IWorkspace workspace = ResourcesPlugin.getWorkspace();
+      final Jg jg = new Jg();
+      IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+        public void run(IProgressMonitor progressMonitor) throws CoreException {
+          jg.main0(arguments, new MergerImpl(), null, // no progressMonitor,
+                          new EP_LogThrowErrorImpl());
+        }
+      };
+      workspace.run(runnable, null);
+      return new Integer(0);
+    } catch (Exception exception) {
+      exception.printStackTrace();
+    }
+
+    return new Integer(1);
+
+  }
 
-	}
- 
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/MergerImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/MergerImpl.java?view=diff&rev=478233&r1=478232&r2=478233
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/MergerImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/MergerImpl.java Wed Nov 22 08:50:38 2006
@@ -31,73 +31,60 @@
 import org.eclipse.jdt.core.jdom.IDOMCompilationUnit;
 
 public class MergerImpl implements org.apache.uima.tools.jcasgen.IMerge {
-	static final String jControlModel = "jMergeCtl.xml";
-	static JControlModel jControlModelInstance = null;
-	public void doMerge(
-		Jg jg,
-		IProgressMonitor progressMonitor,
-		String sourceContents,
-		String targetContainer,
-		String targetPath,
-		String targetClassName,
-		File targetFile)
-		throws IOException {
-		JMerger jMerger = new JMerger();
-		IDOMCompilationUnit sourceCompilationUnit =
-			jMerger.createCompilationUnitForContents(sourceContents);
-		if (targetFile.exists()) {
-			progressMonitor.subTask(
-				jg.getString(
-					"updatingTarget",
-					new Object[] { targetClassName }));
-
-			synchronized (this) {
-				if (null == jControlModelInstance) {
-					String controlModelPath =
-						jg.getClass().getResource(jControlModel).toString();
-					jControlModelInstance =
-						(new JControlModel(controlModelPath));
-				}
-			}
-			jMerger.setControlModel(jControlModelInstance);
-			//			jMerger.setControlModel(
-			//				new JControlModel(
-			//					jg.getClass().getResource(jControlModel).toString()));
-			try {
-
-				jMerger.setSourceCompilationUnit(sourceCompilationUnit);
-				jMerger.setTargetCompilationUnit(
-					jMerger.createCompilationUnitForURI(targetPath));
-			} catch (NullPointerException e) {
-				jg.error.newError(
-					IError.ERROR,
-					jg.getString("nullPtr", new Object[] { targetClassName }),
-					e);
-			}
-            
-			//			jMerger.getTargetPatternDictionary().dump();
-			jMerger.merge();
-
-			FileWriter fw = new FileWriter(targetPath);
-			fw.write(jMerger.getTargetCompilationUnit().getContents());
-			fw.close();
-			//								targetFile.setContents(
-			//									mergedContents,
-			//									true,
-			//									true,
-			//									new SubProgressMonitor(progressMonitor, 1));
-		} else {
-			progressMonitor.subTask(
-				jg.getString("creatingTarget", new Object[] { targetClassName }));
-			(new File(targetContainer)).mkdirs();
-			FileWriter fw = new FileWriter(targetPath);
-			fw.write(sourceContents);
-			fw.close();
-			//								targetFile.setContents(
-			//									new ByteArrayInputStream(sourceContents.getBytes()),
-			//									true,
-			//									true,
-			//									new SubProgressMonitor(progressMonitor, 1));
-		}
-	}
+  static final String jControlModel = "jMergeCtl.xml";
+
+  static JControlModel jControlModelInstance = null;
+
+  public void doMerge(Jg jg, IProgressMonitor progressMonitor, String sourceContents,
+                  String targetContainer, String targetPath, String targetClassName, File targetFile)
+                  throws IOException {
+    JMerger jMerger = new JMerger();
+    IDOMCompilationUnit sourceCompilationUnit = jMerger
+                    .createCompilationUnitForContents(sourceContents);
+    if (targetFile.exists()) {
+      progressMonitor.subTask(jg.getString("updatingTarget", new Object[] { targetClassName }));
+
+      synchronized (this) {
+        if (null == jControlModelInstance) {
+          String controlModelPath = jg.getClass().getResource(jControlModel).toString();
+          jControlModelInstance = (new JControlModel(controlModelPath));
+        }
+      }
+      jMerger.setControlModel(jControlModelInstance);
+      // jMerger.setControlModel(
+      // new JControlModel(
+      // jg.getClass().getResource(jControlModel).toString()));
+      try {
+
+        jMerger.setSourceCompilationUnit(sourceCompilationUnit);
+        jMerger.setTargetCompilationUnit(jMerger.createCompilationUnitForURI(targetPath));
+      } catch (NullPointerException e) {
+        jg.error.newError(IError.ERROR, jg.getString("nullPtr", new Object[] { targetClassName }),
+                        e);
+      }
+
+      // jMerger.getTargetPatternDictionary().dump();
+      jMerger.merge();
+
+      FileWriter fw = new FileWriter(targetPath);
+      fw.write(jMerger.getTargetCompilationUnit().getContents());
+      fw.close();
+      // targetFile.setContents(
+      // mergedContents,
+      // true,
+      // true,
+      // new SubProgressMonitor(progressMonitor, 1));
+    } else {
+      progressMonitor.subTask(jg.getString("creatingTarget", new Object[] { targetClassName }));
+      (new File(targetContainer)).mkdirs();
+      FileWriter fw = new FileWriter(targetPath);
+      fw.write(sourceContents);
+      fw.close();
+      // targetFile.setContents(
+      // new ByteArrayInputStream(sourceContents.getBytes()),
+      // true,
+      // true,
+      // new SubProgressMonitor(progressMonitor, 1));
+    }
+  }
 }

Modified: incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/ProgressMonitorImpl.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/ProgressMonitorImpl.java?view=diff&rev=478233&r1=478232&r2=478233
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/ProgressMonitorImpl.java (original)
+++ incubator/uima/uimaj/trunk/uimaj-ep-jcasgen/src/main/java/org/apache/uima/jcas/jcasgenp/ProgressMonitorImpl.java Wed Nov 22 08:50:38 2006
@@ -23,50 +23,58 @@
 
 public class ProgressMonitorImpl implements org.apache.uima.tools.jcasgen.IProgressMonitor {
   private IProgressMonitor fwd;
-  
+
   ProgressMonitorImpl(IProgressMonitor pm) {
-  	fwd = pm;
+    fwd = pm;
+  }
+
+  public void done() {
+    fwd.done();
   }
-  
-	public void done() {
-		fwd.done();
-	}
 
-	public void beginTask(String name, int totalWorked) {
+  public void beginTask(String name, int totalWorked) {
     fwd.beginTask(name, totalWorked);
- 	}
+  }
 
-	public void subTask(String name) {
+  public void subTask(String name) {
     fwd.subTask(name);
-	}
+  }
 
-	public void worked(int work) {
+  public void worked(int work) {
     fwd.worked(work);
-	}
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
+   */
+  public void internalWorked(double work) {
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
+   */
+  public boolean isCanceled() {
+    return false;
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
+   */
+  public void setCanceled(boolean value) {
+  }
+
+  /*
+   * (non-Javadoc)
+   * 
+   * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
+   */
+  public void setTaskName(String name) {
+  }
 
-	/* (non-Javadoc)
-	 * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double)
-	 */
-	public void internalWorked(double work) {		
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled()
-	 */
-	public boolean isCanceled() {
-		return false;
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean)
-	 */
-	public void setCanceled(boolean value) {	
-	}
-
-	/* (non-Javadoc)
-	 * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String)
-	 */
-	public void setTaskName(String name) {
-	}
-		
 }