();
IMarkerDelta[] deltas = getMarkerDeltas();
- for( int i = 0; i < deltas.length; ++i ) {
+ for (int i = 0; i < deltas.length; ++i)
+ {
IMarkerDelta markerDelta = deltas[i];
if (type == null || (includeSubtypes ? markerDelta.isSubtypeOf(type) : markerDelta.getType().equals(type)))
{
matching.add(markerDelta);
}
}
- if ( matching.size() == 0 )
+ if (matching.size() == 0)
{
return NO_MARKER_DELTAS;
}
@@ -63,15 +66,17 @@ public IMarkerDelta[] findMarkerDeltas(String type, boolean includeSubtypes) {
/**
* @see com.aptana.ide.core.resources.IUniformResourceChangeEvent#getResource()
*/
- public IUniformResource getResource() {
+ public IUniformResource getResource()
+ {
return resource;
}
/**
* @see com.aptana.ide.core.resources.IUniformResourceChangeEvent#getMarkerDeltas()
*/
- public IMarkerDelta[] getMarkerDeltas() {
- if ( deltas == null )
+ public IMarkerDelta[] getMarkerDeltas()
+ {
+ if (deltas == null)
{
return NO_MARKER_DELTAS;
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/logging/Messages.java b/plugins/com.aptana.core/src/com/aptana/core/logging/Messages.java
index f660b60ca4..e9f9cdd296 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/logging/Messages.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/logging/Messages.java
@@ -11,8 +11,8 @@
/**
* Messages class for internationalization
+ *
* @author Ingo Muschenetz
- *
*/
public final class Messages extends NLS
{
@@ -27,7 +27,7 @@ private Messages()
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
-
+
public static String IdeLog_ERROR;
public static String IdeLog_File_Written_To;
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/AbstractUniformResource.java b/plugins/com.aptana.core/src/com/aptana/core/resources/AbstractUniformResource.java
index 44b76e2dc6..414cab5fb6 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/AbstractUniformResource.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/AbstractUniformResource.java
@@ -11,28 +11,31 @@
/**
* @author Max Stepanov
- *
*/
-public abstract class AbstractUniformResource extends PlatformObject implements IUniformResource {
+public abstract class AbstractUniformResource extends PlatformObject implements IUniformResource
+{
/**
*
*/
- protected AbstractUniformResource() {
+ protected AbstractUniformResource()
+ {
super();
}
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
- public boolean equals(Object obj) {
- return obj instanceof IUniformResource && getURI().equals(((IUniformResource)obj).getURI());
+ public boolean equals(Object obj)
+ {
+ return obj instanceof IUniformResource && getURI().equals(((IUniformResource) obj).getURI());
}
/**
* @see java.lang.Object#hashCode()
*/
- public int hashCode() {
+ public int hashCode()
+ {
return getURI().hashCode();
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/FileStoreUniformResource.java b/plugins/com.aptana.core/src/com/aptana/core/resources/FileStoreUniformResource.java
index 6e78a282ae..2d83d8db12 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/FileStoreUniformResource.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/FileStoreUniformResource.java
@@ -14,24 +14,27 @@
/**
* @author Max Stepanov
- *
*/
-public final class FileStoreUniformResource extends AbstractUniformResource {
+public final class FileStoreUniformResource extends AbstractUniformResource
+{
private final IFileStore fileStore;
-
+
/**
*
*/
- public FileStoreUniformResource(IFileStore fileStore) {
+ public FileStoreUniformResource(IFileStore fileStore)
+ {
super();
this.fileStore = fileStore;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see com.aptana.core.resources.IUniformResource#getURI()
*/
- public URI getURI() {
+ public URI getURI()
+ {
return fileStore.toURI();
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/ISocketMessagesHandler.java b/plugins/com.aptana.core/src/com/aptana/core/resources/ISocketMessagesHandler.java
index 81c32ca9ba..9231287f47 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/ISocketMessagesHandler.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/ISocketMessagesHandler.java
@@ -12,7 +12,7 @@
/**
* The interface to implement the handlers for addressing the requests/messages from the underlying CLI and return back
* with the responses.
- *
+ *
* @author pinnamuri
*/
public interface ISocketMessagesHandler
@@ -21,7 +21,7 @@ public interface ISocketMessagesHandler
/**
* Addresses the request either by prompting a UI to the user, or just computes a JSON object from existing answers,
* and will return back a response.
- *
+ *
* @param request
* @return
*/
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResource.java b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResource.java
index d668357776..aa88aac57a 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResource.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResource.java
@@ -13,13 +13,13 @@
/**
* @author Max Stepanov
- *
*/
-public interface IUniformResource extends IAdaptable {
-
+public interface IUniformResource extends IAdaptable
+{
+
/**
* Resource URI
- *
+ *
* @return URI
*/
URI getURI();
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeEvent.java b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeEvent.java
index 7049a4a183..3dfeda5982 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeEvent.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeEvent.java
@@ -11,47 +11,46 @@
/**
* @author Max Stepanov
- *
*/
-public interface IUniformResourceChangeEvent {
+public interface IUniformResourceChangeEvent
+{
/**
- * Returns the changes to markers on the corresponding resource.
- * Returns an empty array if no markers changed.
- *
+ * Returns the changes to markers on the corresponding resource. Returns an empty array if no markers changed.
+ *
* @return the marker deltas
*/
IMarkerDelta[] getMarkerDeltas();
/**
- * Returns all marker deltas of the specified type that are associated
- * with resource deltas for this event. If includeSubtypes
- * is false
, only marker deltas whose type exactly matches
- * the given type are returned. Returns an empty array if there
- * are no matching marker deltas.
+ * Returns all marker deltas of the specified type that are associated with resource deltas for this event. If
+ * includeSubtypes
is false
, only marker deltas whose type exactly matches the given type
+ * are returned. Returns an empty array if there are no matching marker deltas.
*
- * Calling this method is equivalent to walking the entire resource
- * delta for this event, and collecting all marker deltas of a given type.
- * The speed of this method will be proportional to the number of changed
- * markers, regardless of the size of the resource delta tree.
+ * Calling this method is equivalent to walking the entire resource delta for this event, and collecting all marker
+ * deltas of a given type. The speed of this method will be proportional to the number of changed markers,
+ * regardless of the size of the resource delta tree.
*
- * @param type the type of marker to consider, or null
to indicate all types
- * @param includeSubtypes whether or not to consider sub-types of the given type
+ *
+ * @param type
+ * the type of marker to consider, or null
to indicate all types
+ * @param includeSubtypes
+ * whether or not to consider sub-types of the given type
* @return an array of marker deltas
*/
IMarkerDelta[] findMarkerDeltas(String type, boolean includeSubtypes);
-
+
/**
* getResource
- *
+ *
* @return IUniformResource
*/
IUniformResource getResource();
/**
* Returns an object identifying the source of this event.
- *
- * @return an object identifying the source of this event
+ *
+ * @return an object identifying the source of this event
* @see java.util.EventObject
*/
Object getSource();
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeListener.java b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeListener.java
index e88aa77f09..604f6ddcbe 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeListener.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceChangeListener.java
@@ -11,13 +11,13 @@
/**
* @author Max Stepanov
- *
*/
-public interface IUniformResourceChangeListener extends EventListener {
+public interface IUniformResourceChangeListener extends EventListener
+{
/**
* resourceChanged
- *
+ *
* @param event
*/
void resourceChanged(IUniformResourceChangeEvent event);
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceMarker.java b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceMarker.java
index 10bc1a7d38..9e9a05d4a0 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceMarker.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/IUniformResourceMarker.java
@@ -11,12 +11,12 @@
/**
* @author Max Stepanov
- *
*/
-public interface IUniformResourceMarker extends IMarker {
+public interface IUniformResourceMarker extends IMarker
+{
/**
* getUniformResource
- *
+ *
* @return IUniformResource
*/
IUniformResource getUniformResource();
diff --git a/plugins/com.aptana.core/src/com/aptana/core/resources/UniformResourceStorage.java b/plugins/com.aptana.core/src/com/aptana/core/resources/UniformResourceStorage.java
index 7be7a50757..beaee437d5 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/resources/UniformResourceStorage.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/resources/UniformResourceStorage.java
@@ -27,7 +27,8 @@
* @author Max Stepanov
*/
// TODO: rework using EFS
-public abstract class UniformResourceStorage extends PlatformObject implements IStorage {
+public abstract class UniformResourceStorage extends PlatformObject implements IStorage
+{
private long timestamp = -1;
private long expires = -1;
@@ -35,7 +36,8 @@ public abstract class UniformResourceStorage extends PlatformObject implements I
/**
* UniformResourceStorage
*/
- protected UniformResourceStorage() {
+ protected UniformResourceStorage()
+ {
super();
}
@@ -50,18 +52,20 @@ protected UniformResourceStorage() {
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
@SuppressWarnings("rawtypes")
- public Object getAdapter(Class adapter) {
- if (IUniformResource.class == adapter) {
- return new AbstractUniformResource() {
+ public Object getAdapter(Class adapter)
+ {
+ if (IUniformResource.class == adapter)
+ {
+ return new AbstractUniformResource()
+ {
/*
* (non-Javadoc)
- *
- * @see
- * org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang
- * .Class)
+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang .Class)
*/
- public Object getAdapter(Class adapter) {
- if (IStorage.class == adapter) {
+ public Object getAdapter(Class adapter)
+ {
+ if (IStorage.class == adapter)
+ {
return UniformResourceStorage.this;
}
return super.getAdapter(adapter);
@@ -69,10 +73,10 @@ public Object getAdapter(Class adapter) {
/*
* (non-Javadoc)
- *
* @see com.aptana.ide.core.resources.IUniformResource#getURI()
*/
- public URI getURI() {
+ public URI getURI()
+ {
return UniformResourceStorage.this.getURI();
}
@@ -85,14 +89,16 @@ public URI getURI() {
/**
* @see java.lang.Object#equals(java.lang.Object)
*/
- public boolean equals(Object obj) {
+ public boolean equals(Object obj)
+ {
return obj instanceof UniformResourceStorage && getURI().equals(((UniformResourceStorage) obj).getURI());
}
/**
* @see java.lang.Object#hashCode()
*/
- public int hashCode() {
+ public int hashCode()
+ {
return getURI().hashCode();
}
@@ -101,36 +107,49 @@ public int hashCode() {
*
* @return boolean
*/
- public boolean isValid() {
- if (timestamp == -1) {
+ public boolean isValid()
+ {
+ if (timestamp == -1)
+ {
return false;
}
- if (expires >= System.currentTimeMillis()) {
+ if (expires >= System.currentTimeMillis())
+ {
return true;
}
- try {
+ try
+ {
URLConnection connection = getURI().toURL().openConnection();
- if (connection instanceof HttpURLConnection) {
+ if (connection instanceof HttpURLConnection)
+ {
connection.setIfModifiedSince(timestamp);
((HttpURLConnection) connection).setRequestMethod("HEAD"); //$NON-NLS-1$
}
connection.connect();
- if (connection instanceof HttpURLConnection) {
+ if (connection instanceof HttpURLConnection)
+ {
HttpURLConnection httpConnection = (HttpURLConnection) connection;
long lastModified = httpConnection.getLastModified();
- if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED || (lastModified != 0 && timestamp >= lastModified)) {
+ if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED
+ || (lastModified != 0 && timestamp >= lastModified))
+ {
expires = System.currentTimeMillis();
long expiration = connection.getExpiration();
long date = connection.getDate();
- if (expiration != 0 && date != 0 && expiration > date) {
+ if (expiration != 0 && date != 0 && expiration > date)
+ {
expires += (expiration - date);
- } else {
+ }
+ else
+ {
expires += 10 * 1000; // 10 sec
}
return true;
}
}
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
IdeLog.logError(CorePlugin.getDefault(), e);
}
return false;
@@ -139,39 +158,53 @@ public boolean isValid() {
/**
* @see org.eclipse.core.resources.IStorage#getContents()
*/
- public InputStream getContents() throws CoreException {
- try {
+ public InputStream getContents() throws CoreException
+ {
+ try
+ {
URLConnection connection = getURI().toURL().openConnection();
connection.connect();
expires = System.currentTimeMillis();
long expiration = connection.getExpiration();
long date = connection.getDate();
- if (expiration != 0 && date != 0 && expiration > date) {
+ if (expiration != 0 && date != 0 && expiration > date)
+ {
expires += (expiration - date);
- } else {
+ }
+ else
+ {
expires += 10 * 1000; // 10 sec
}
timestamp = connection.getLastModified();
return connection.getInputStream();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
throw new CoreException(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, IStatus.OK, "Open stream error", e)); //$NON-NLS-1$
}
}
- public boolean exists() {
- try {
+ public boolean exists()
+ {
+ try
+ {
URLConnection connection = getURI().toURL().openConnection();
- if (connection instanceof HttpURLConnection) {
+ if (connection instanceof HttpURLConnection)
+ {
((HttpURLConnection) connection).setRequestMethod("HEAD"); //$NON-NLS-1$
}
connection.connect();
- if (connection instanceof HttpURLConnection) {
+ if (connection instanceof HttpURLConnection)
+ {
HttpURLConnection httpConnection = (HttpURLConnection) connection;
- if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK) {
+ if (httpConnection.getResponseCode() == HttpURLConnection.HTTP_OK)
+ {
return true;
}
}
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
IdeLog.logError(CorePlugin.getDefault(), e);
}
return false;
@@ -180,18 +213,22 @@ public boolean exists() {
/**
* @see org.eclipse.core.resources.IStorage#getFullPath()
*/
- public IPath getFullPath() {
+ public IPath getFullPath()
+ {
return null;
}
/**
* @see org.eclipse.core.resources.IStorage#getName()
*/
- public String getName() {
+ public String getName()
+ {
String name = getURI().getPath();
- if (name != null) {
+ if (name != null)
+ {
int index = name.lastIndexOf('/');
- if (index >= 0) {
+ if (index >= 0)
+ {
name = name.substring(index + 1);
}
}
@@ -201,7 +238,8 @@ public String getName() {
/**
* @see org.eclipse.core.resources.IStorage#isReadOnly()
*/
- public boolean isReadOnly() {
+ public boolean isReadOnly()
+ {
return true;
}
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/ExpiringMap.java b/plugins/com.aptana.core/src/com/aptana/core/util/ExpiringMap.java
index e21c2b982a..1adeb9376c 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/ExpiringMap.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/ExpiringMap.java
@@ -14,157 +14,194 @@
import java.util.Set;
/**
- * @author Max Stepanov
- * TODO Merge/reuse IObjectPool? Very similar uses/implementations!
+ * @author Max Stepanov TODO Merge/reuse IObjectPool? Very similar uses/implementations!
*/
-public class ExpiringMap implements Map {
+public class ExpiringMap implements Map
+{
private LinkedHashMap map = new LinkedHashMap();
private long maxObjectTTL;
-
- public ExpiringMap(long maxObjectTTL) {
+ public ExpiringMap(long maxObjectTTL)
+ {
super();
this.maxObjectTTL = maxObjectTTL;
}
-
- private boolean hasExpired(Object key, Item item) {
+
+ private boolean hasExpired(Object key, Item item)
+ {
long now = System.currentTimeMillis();
- if (item.creationTime + maxObjectTTL < now) {
+ if (item.creationTime + maxObjectTTL < now)
+ {
map.remove(key);
return true;
}
return false;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#clear()
*/
- public void clear() {
+ public void clear()
+ {
map.clear();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#containsKey(java.lang.Object)
*/
- public boolean containsKey(Object key) {
+ public boolean containsKey(Object key)
+ {
throw new UnsupportedOperationException();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#containsValue(java.lang.Object)
*/
- public boolean containsValue(Object value) {
+ public boolean containsValue(Object value)
+ {
throw new UnsupportedOperationException();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#entrySet()
*/
- public Set> entrySet() {
+ public Set> entrySet()
+ {
throw new UnsupportedOperationException();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#get(java.lang.Object)
*/
- public V get(Object key) {
+ public V get(Object key)
+ {
Item v = map.get(key);
- if (v != null && !hasExpired(key, v)) {
+ if (v != null && !hasExpired(key, v))
+ {
return v.object;
}
return null;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#isEmpty()
*/
- public boolean isEmpty() {
+ public boolean isEmpty()
+ {
throw new UnsupportedOperationException();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#keySet()
*/
- public Set keySet() {
+ public Set keySet()
+ {
return map.keySet();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#put(java.lang.Object, java.lang.Object)
*/
- public V put(K key, V value) {
- Item v = map.put(key, new Item(value));
- if (v != null) {
+ public V put(K key, V value)
+ {
+ Item v = map.put(key, new Item(value));
+ if (v != null)
+ {
return v.object;
}
return null;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#putAll(java.util.Map)
*/
- public void putAll(Map extends K, ? extends V> t) {
+ public void putAll(Map extends K, ? extends V> t)
+ {
Map all = new LinkedHashMap();
- for (Entry extends K, ? extends V> i : t.entrySet()) {
+ for (Entry extends K, ? extends V> i : t.entrySet())
+ {
all.put(i.getKey(), new Item(i.getValue()));
}
map.putAll(all);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#remove(java.lang.Object)
*/
- public V remove(Object key) {
+ public V remove(Object key)
+ {
Item v = map.remove(key);
- if (v != null && !hasExpired(key, v)) {
+ if (v != null && !hasExpired(key, v))
+ {
return v.object;
}
return null;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#size()
*/
- public int size() {
+ public int size()
+ {
throw new UnsupportedOperationException();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.util.Map#values()
*/
- public Collection values() {
+ public Collection values()
+ {
throw new UnsupportedOperationException();
}
- private class Item {
-
+ private class Item
+ {
+
protected V object;
protected long creationTime;
-
- public Item(V object) {
+
+ public Item(V object)
+ {
this.object = object;
this.creationTime = System.currentTimeMillis();
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@SuppressWarnings("rawtypes")
@Override
- public boolean equals(Object obj) {
- if (obj instanceof ExpiringMap.Item) {
+ public boolean equals(Object obj)
+ {
+ if (obj instanceof ExpiringMap.Item)
+ {
return object == ((ExpiringMap.Item) obj).object
- || (object != null && object.equals(((ExpiringMap.Item) obj).object));
+ || (object != null && object.equals(((ExpiringMap.Item) obj).object));
}
return false;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
- public int hashCode() {
+ public int hashCode()
+ {
return object != null ? object.hashCode() : 0;
}
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/FileUtil.java b/plugins/com.aptana.core/src/com/aptana/core/util/FileUtil.java
index 80044fb044..193ef46063 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/FileUtil.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/FileUtil.java
@@ -224,7 +224,8 @@ public static boolean deleteRecursively(File dir)
boolean result = true;
if (dir.isDirectory())
{
- // On *nix systems, defer to rm -rf. If for some reason it faiils, fall back to recursive delete via Java API
+ // On *nix systems, defer to rm -rf. If for some reason it faiils, fall back to recursive delete via Java
+ // API
if (!PlatformUtil.isWindows())
{
IStatus status = new ProcessRunner().runInBackground("/bin/rm", "-rf", dir.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/IObjectPool.java b/plugins/com.aptana.core/src/com/aptana/core/util/IObjectPool.java
index 4bad8eaaa7..c8c23ab433 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/IObjectPool.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/IObjectPool.java
@@ -7,7 +7,8 @@
*/
package com.aptana.core.util;
-public interface IObjectPool {
+public interface IObjectPool
+{
/**
* Create a new instance of a managed object in the pool.
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/ImmutableTuple.java b/plugins/com.aptana.core/src/com/aptana/core/util/ImmutableTuple.java
index 42c8f90040..f5da62eb3f 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/ImmutableTuple.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/ImmutableTuple.java
@@ -85,7 +85,8 @@ public int hashCode()
@Override
public String toString()
{
- return StringUtil.concat("Tuple [", first != null ? first.toString() : "null", " -- ", second != null ? second.toString() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- : "null", "]"); //$NON-NLS-1$//$NON-NLS-2$
+ return StringUtil.concat(
+ "Tuple [", first != null ? first.toString() : "null", " -- ", second != null ? second.toString() //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ : "null", "]"); //$NON-NLS-1$//$NON-NLS-2$
}
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/KeepAliveObjectPool.java b/plugins/com.aptana.core/src/com/aptana/core/util/KeepAliveObjectPool.java
index fea8ab0e54..8240ade76c 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/KeepAliveObjectPool.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/KeepAliveObjectPool.java
@@ -16,14 +16,16 @@
import com.aptana.core.CorePlugin;
import com.aptana.core.logging.IdeLog;
-public abstract class KeepAliveObjectPool implements IObjectPool {
+public abstract class KeepAliveObjectPool implements IObjectPool
+{
private final List locked;
private final Map unlocked;
private final ConnectionReaper reaper;
private final int releaseTime;
- public KeepAliveObjectPool(int releaseTime) {
+ public KeepAliveObjectPool(int releaseTime)
+ {
this.releaseTime = releaseTime;
locked = new ArrayList();
unlocked = new LinkedHashMap();
@@ -31,19 +33,24 @@ public KeepAliveObjectPool(int releaseTime) {
reaper = new ConnectionReaper();
}
- protected void start() {
+ protected void start()
+ {
reaper.start();
}
- public synchronized void checkIn(T t) {
+ public synchronized void checkIn(T t)
+ {
locked.remove(t);
unlocked.put(t, System.currentTimeMillis());
}
- public synchronized T checkOut() {
+ public synchronized T checkOut()
+ {
// returns the first valid connection from the unused queue
- for (T c : unlocked.keySet()) {
- if (validate(c)) {
+ for (T c : unlocked.keySet())
+ {
+ if (validate(c))
+ {
unlocked.remove(c);
locked.add(c);
return c;
@@ -56,30 +63,38 @@ public synchronized T checkOut() {
return c;
}
- public synchronized void dispose() {
- for (T c : unlocked.keySet()) {
+ public synchronized void dispose()
+ {
+ for (T c : unlocked.keySet())
+ {
expire(c);
}
unlocked.clear();
- if (locked.size() > 0) {
+ if (locked.size() > 0)
+ {
IdeLog.logWarning(CorePlugin.getDefault(),
- MessageFormat.format(
- "Killed a connection pool that still has {0} locked items", locked.size())); //$NON-NLS-1$
+ MessageFormat.format("Killed a connection pool that still has {0} locked items", locked.size())); //$NON-NLS-1$
locked.clear();
}
reaper.exit();
}
- protected synchronized void reap() {
+ protected synchronized void reap()
+ {
long now = System.currentTimeMillis();
- for (T c : unlocked.keySet()) {
- if ((now - unlocked.get(c)) > timeToRelease()) {
+ for (T c : unlocked.keySet())
+ {
+ if ((now - unlocked.get(c)) > timeToRelease())
+ {
// time to release the connection
unlocked.remove(c);
expire(c);
- } else {
+ }
+ else
+ {
// keeps the connection alive unless it no longer validates
- if (!validate(c)) {
+ if (!validate(c))
+ {
unlocked.remove(c);
expire(c);
}
@@ -87,32 +102,41 @@ protected synchronized void reap() {
}
}
- private int timeToRelease() {
+ private int timeToRelease()
+ {
int divider = ((unlocked.size() + locked.size()) ^ 2);
return releaseTime / (divider > 0 ? divider : 1);
}
- private class ConnectionReaper extends Thread {
+ private class ConnectionReaper extends Thread
+ {
private static final long INTERVAL = 15000; // 15 seconds
private boolean isRunning;
- public ConnectionReaper() {
+ public ConnectionReaper()
+ {
isRunning = true;
}
- public void run() {
- while (isRunning) {
- try {
+ public void run()
+ {
+ while (isRunning)
+ {
+ try
+ {
sleep(INTERVAL);
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
}
reap();
}
}
- public void exit() {
+ public void exit()
+ {
isRunning = false;
}
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/ObjectPool.java b/plugins/com.aptana.core/src/com/aptana/core/util/ObjectPool.java
index 27d264bd6f..7fb77d1170 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/ObjectPool.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/ObjectPool.java
@@ -38,22 +38,26 @@ public ObjectPool()
this(DEFAULT_EXPIRATION);
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see com.aptana.core.util.IObjectPool#create()
*/
public abstract T create();
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see com.aptana.core.util.IObjectPool#validate(T)
*/
public abstract boolean validate(T o);
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see com.aptana.core.util.IObjectPool#expire(T)
*/
public abstract void expire(T o);
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see com.aptana.core.util.IObjectPool#checkOut()
*/
public synchronized T checkOut()
@@ -98,7 +102,8 @@ public synchronized T checkOut()
return t;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see com.aptana.core.util.IObjectPool#checkIn(T)
*/
public synchronized void checkIn(T t)
@@ -107,7 +112,8 @@ public synchronized void checkIn(T t)
unlocked.put(t, System.currentTimeMillis());
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
* @see com.aptana.core.util.IObjectPool#cleanup()
*/
public synchronized void dispose()
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/ProcessRunner.java b/plugins/com.aptana.core/src/com/aptana/core/util/ProcessRunner.java
index 1dac7d3b03..5dd7a70fea 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/ProcessRunner.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/ProcessRunner.java
@@ -271,7 +271,8 @@ public IStatus runInBackground(IPath workingDirectory, Map envir
}
else
{
- CollectionsUtil.addToList(arguments, ">", outFile.getAbsolutePath(), "2>", errFile.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
+ CollectionsUtil.addToList(arguments,
+ ">", outFile.getAbsolutePath(), "2>", errFile.getAbsolutePath()); //$NON-NLS-1$ //$NON-NLS-2$
p = run(workingDirectory, environment, arguments.toArray(new String[arguments.size()]));
}
return processData(p, outFile, errFile);
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/ProgressMonitorInterrupter.java b/plugins/com.aptana.core/src/com/aptana/core/util/ProgressMonitorInterrupter.java
index 986ba582ac..b4a1db13f1 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/ProgressMonitorInterrupter.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/ProgressMonitorInterrupter.java
@@ -23,9 +23,11 @@
*
* @author Max Stepanov
*/
-public class ProgressMonitorInterrupter {
+public class ProgressMonitorInterrupter
+{
- public interface InterruptDelegate {
+ public interface InterruptDelegate
+ {
public void interrupt();
}
@@ -35,61 +37,81 @@ public interface InterruptDelegate {
private final Thread thread;
private final MonitorThread monitorThread;
- private static Map delegates = Collections.synchronizedMap(new WeakHashMap());
+ private static Map delegates = Collections
+ .synchronizedMap(new WeakHashMap());
/**
*
*/
- public ProgressMonitorInterrupter(IProgressMonitor monitor) {
+ public ProgressMonitorInterrupter(IProgressMonitor monitor)
+ {
this.monitor = monitor != null ? monitor : new NullProgressMonitor();
this.thread = Thread.currentThread();
monitorThread = new MonitorThread();
monitorThread.start();
}
- public void dispose() {
+ public void dispose()
+ {
monitorThread.interrupt();
}
/**
* Sets interrupt delegate for the current thread
+ *
* @param delegate
*/
- public static void setCurrentThreadInterruptDelegate(InterruptDelegate delegate) {
- if (delegate != null) {
+ public static void setCurrentThreadInterruptDelegate(InterruptDelegate delegate)
+ {
+ if (delegate != null)
+ {
delegates.put(Thread.currentThread(), delegate);
- } else {
+ }
+ else
+ {
delegates.remove(Thread.currentThread());
}
}
- private static void interruptThread(Thread thread) {
+ private static void interruptThread(Thread thread)
+ {
InterruptDelegate delegate = delegates.get(thread);
- if (delegate != null) {
+ if (delegate != null)
+ {
delegate.interrupt();
- } else {
+ }
+ else
+ {
thread.interrupt();
}
}
- private class MonitorThread extends Thread {
+ private class MonitorThread extends Thread
+ {
- public MonitorThread() {
+ public MonitorThread()
+ {
super("Progress Monitor Thread"); //$NON-NLS-1$
setDaemon(true);
}
@Override
- public void run() {
- try {
- while (!interrupted()) {
- if (monitor.isCanceled()) {
+ public void run()
+ {
+ try
+ {
+ while (!interrupted())
+ {
+ if (monitor.isCanceled())
+ {
interruptThread(thread);
break;
}
sleep(CHECK_INTERVAL);
}
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
Thread.currentThread().interrupt();
}
}
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/SourcePrinter.java b/plugins/com.aptana.core/src/com/aptana/core/util/SourcePrinter.java
index 71c196d1f3..bed0c89231 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/SourcePrinter.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/SourcePrinter.java
@@ -39,7 +39,7 @@ public SourcePrinter(String indent)
this._currentIndent = StringUtil.EMPTY;
this._newLine = DEFAULT_NEWLINE;
}
-
+
/**
* Decrease the current line indent count
*
diff --git a/plugins/com.aptana.core/src/com/aptana/core/util/TimeZoneUtil.java b/plugins/com.aptana.core/src/com/aptana/core/util/TimeZoneUtil.java
index 935b07ac6b..94cfc67167 100644
--- a/plugins/com.aptana.core/src/com/aptana/core/util/TimeZoneUtil.java
+++ b/plugins/com.aptana.core/src/com/aptana/core/util/TimeZoneUtil.java
@@ -14,11 +14,13 @@
/**
* @author Max Stepanov
*/
-public final class TimeZoneUtil {
+public final class TimeZoneUtil
+{
private static final List commonTimeZones = new ArrayList();
- static {
+ static
+ {
commonTimeZones.add("EST"); //$NON-NLS-1$
commonTimeZones.add("CST"); //$NON-NLS-1$
commonTimeZones.add("MST"); //$NON-NLS-1$
@@ -29,25 +31,32 @@ public final class TimeZoneUtil {
/**
*
*/
- private TimeZoneUtil() {
+ private TimeZoneUtil()
+ {
}
- public static String getCommonTimeZone(String[] timezones) {
- if (timezones == null || timezones.length == 0) {
+ public static String getCommonTimeZone(String[] timezones)
+ {
+ if (timezones == null || timezones.length == 0)
+ {
return StringUtil.EMPTY;
}
- for (String i : timezones) {
- if (commonTimeZones.contains(i)) {
+ for (String i : timezones)
+ {
+ if (commonTimeZones.contains(i))
+ {
return i;
}
}
- for (String i : timezones) {
+ for (String i : timezones)
+ {
if (i.startsWith("GMT")) { //$NON-NLS-1$
return i;
}
}
- for (String i : timezones) {
+ for (String i : timezones)
+ {
if (i.startsWith("Etc/GMT")) { //$NON-NLS-1$
return i;
}