Modified: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java (original)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java Mon Aug 2 17:08:03 2010
@@ -19,12 +19,10 @@
package org.apache.felix.sigil.common.osgi;
-
import java.io.Serializable;
import org.osgi.framework.Version;
-
public class VersionRange implements Serializable
{
@@ -32,17 +30,16 @@ public class VersionRange implements Ser
*
*/
private static final long serialVersionUID = 1L;
- public static final Version INFINITE_VERSION = new Version( Integer.MAX_VALUE, Integer.MAX_VALUE,
- Integer.MAX_VALUE, "" );
- public static final VersionRange ANY_VERSION = new VersionRange( false, Version.emptyVersion, INFINITE_VERSION,
- true );
+ public static final Version INFINITE_VERSION = new Version(Integer.MAX_VALUE,
+ Integer.MAX_VALUE, Integer.MAX_VALUE, "");
+ public static final VersionRange ANY_VERSION = new VersionRange(false,
+ Version.emptyVersion, INFINITE_VERSION, true);
private boolean openFloor;
private Version floor;
private Version ceiling;
private boolean openCeiling;
-
/**
* Interval constructor
*
@@ -51,7 +48,7 @@ public class VersionRange implements Ser
* @param ceiling The upper bound version of the range.
* @param openCeiling Whether the upper bound of the range is inclusive (false) or exclusive (true).
*/
- public VersionRange( boolean openFloor, Version floor, Version ceiling, boolean openCeiling )
+ public VersionRange(boolean openFloor, Version floor, Version ceiling, boolean openCeiling)
{
this.openFloor = openFloor;
this.floor = floor;
@@ -59,14 +56,13 @@ public class VersionRange implements Ser
this.openCeiling = openCeiling;
}
-
/**
* atLeast constructor
*
* @param openFloor
* @param floor
*/
- public VersionRange( Version atLeast )
+ public VersionRange(Version atLeast)
{
this.openFloor = false;
this.floor = atLeast;
@@ -74,202 +70,198 @@ public class VersionRange implements Ser
this.openCeiling = true;
}
-
- public static VersionRange parseVersionRange( String val ) throws IllegalArgumentException, NumberFormatException
+ public static VersionRange parseVersionRange(String val)
+ throws IllegalArgumentException, NumberFormatException
{
- if ( val == null || val.trim().length() == 0 )
+ if (val == null || val.trim().length() == 0)
{
return ANY_VERSION;
}
boolean openFloor;
boolean openCeiling;
- val = val.replaceAll( "\\s", "" );
- val = val.replaceAll( "\"", "" );
- int fst = val.charAt( 0 );
- if ( fst == '[' )
+ val = val.replaceAll("\\s", "");
+ val = val.replaceAll("\"", "");
+ int fst = val.charAt(0);
+ if (fst == '[')
{
openFloor = false;
}
- else if ( fst == '(' )
+ else if (fst == '(')
{
openFloor = true;
}
else
{
- Version atLeast = VersionTable.getVersion( val );
- return new VersionRange( atLeast );
+ Version atLeast = VersionTable.getVersion(val);
+ return new VersionRange(atLeast);
}
- int lst = val.charAt( val.length() - 1 );
- if ( lst == ']' )
+ int lst = val.charAt(val.length() - 1);
+ if (lst == ']')
{
openCeiling = false;
}
- else if ( lst == ')' )
+ else if (lst == ')')
{
openCeiling = true;
}
else
{
- throw new IllegalArgumentException( "illegal version range syntax " + val
- + ": range must end in ')' or ']'" );
+ throw new IllegalArgumentException("illegal version range syntax " + val
+ + ": range must end in ')' or ']'");
}
- String inner = val.substring( 1, val.length() - 1 );
- String[] floorCeiling = inner.split( "," );
- if ( floorCeiling.length != 2 )
+ String inner = val.substring(1, val.length() - 1);
+ String[] floorCeiling = inner.split(",");
+ if (floorCeiling.length != 2)
{
- throw new IllegalArgumentException( "illegal version range syntax " + "too many commas" );
+ throw new IllegalArgumentException("illegal version range syntax "
+ + "too many commas");
}
- Version floor = VersionTable.getVersion( floorCeiling[0] );
- Version ceiling = "*".equals( floorCeiling[1] ) ? INFINITE_VERSION : Version.parseVersion( floorCeiling[1] );
- return new VersionRange( openFloor, floor, ceiling, openCeiling );
+ Version floor = VersionTable.getVersion(floorCeiling[0]);
+ Version ceiling = "*".equals(floorCeiling[1]) ? INFINITE_VERSION
+ : Version.parseVersion(floorCeiling[1]);
+ return new VersionRange(openFloor, floor, ceiling, openCeiling);
}
-
public Version getCeiling()
{
return ceiling;
}
-
public Version getFloor()
{
return floor;
}
-
public boolean isOpenCeiling()
{
return openCeiling;
}
-
public boolean isOpenFloor()
{
return openFloor;
}
-
public boolean isPointVersion()
{
- return !openFloor && !openCeiling && floor.equals( ceiling );
+ return !openFloor && !openCeiling && floor.equals(ceiling);
}
-
/**
* test a version to see if it falls in the range
*
* @param version
* @return
*/
- public boolean contains( Version version )
+ public boolean contains(Version version)
{
- if ( version.equals( INFINITE_VERSION ) )
+ if (version.equals(INFINITE_VERSION))
{
- return ceiling.equals( INFINITE_VERSION );
+ return ceiling.equals(INFINITE_VERSION);
}
else
{
- return ( version.compareTo( floor ) > 0 && version.compareTo( ceiling ) < 0 )
- || ( !openFloor && version.equals( floor ) ) || ( !openCeiling && version.equals( ceiling ) );
+ return (version.compareTo(floor) > 0 && version.compareTo(ceiling) < 0)
+ || (!openFloor && version.equals(floor))
+ || (!openCeiling && version.equals(ceiling));
}
}
-
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
- result = prime * result + ( ( ceiling == null ) ? 0 : ceiling.hashCode() );
- result = prime * result + ( ( floor == null ) ? 0 : floor.hashCode() );
- result = prime * result + ( openCeiling ? 1231 : 1237 );
- result = prime * result + ( openFloor ? 1231 : 1237 );
+ result = prime * result + ((ceiling == null) ? 0 : ceiling.hashCode());
+ result = prime * result + ((floor == null) ? 0 : floor.hashCode());
+ result = prime * result + (openCeiling ? 1231 : 1237);
+ result = prime * result + (openFloor ? 1231 : 1237);
return result;
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
- if ( this == obj )
+ if (this == obj)
return true;
- if ( obj == null )
+ if (obj == null)
return false;
- if ( getClass() != obj.getClass() )
+ if (getClass() != obj.getClass())
return false;
- final VersionRange other = ( VersionRange ) obj;
- if ( ceiling == null )
+ final VersionRange other = (VersionRange) obj;
+ if (ceiling == null)
{
- if ( other.ceiling != null )
+ if (other.ceiling != null)
return false;
}
- else if ( !ceiling.equals( other.ceiling ) )
+ else if (!ceiling.equals(other.ceiling))
return false;
- if ( floor == null )
+ if (floor == null)
{
- if ( other.floor != null )
+ if (other.floor != null)
return false;
}
- else if ( !floor.equals( other.floor ) )
+ else if (!floor.equals(other.floor))
return false;
- if ( openCeiling != other.openCeiling )
+ if (openCeiling != other.openCeiling)
return false;
- if ( openFloor != other.openFloor )
+ if (openFloor != other.openFloor)
return false;
return true;
}
-
@Override
public String toString()
{
- if ( ANY_VERSION.equals( this ) )
+ if (ANY_VERSION.equals(this))
{
- return makeString( openFloor, Version.emptyVersion, INFINITE_VERSION, openCeiling );
+ return makeString(openFloor, Version.emptyVersion, INFINITE_VERSION,
+ openCeiling);
}
- return makeString( openFloor, floor, ceiling, openCeiling );
+ return makeString(openFloor, floor, ceiling, openCeiling);
}
-
- private String makeString( boolean openFloor, Version floor, Version ceiling, boolean openCeiling )
+ private String makeString(boolean openFloor, Version floor, Version ceiling,
+ boolean openCeiling)
{
- StringBuffer vr = new StringBuffer( 32 );
- if ( INFINITE_VERSION.equals( ceiling ) )
+ StringBuffer vr = new StringBuffer(32);
+ if (INFINITE_VERSION.equals(ceiling))
{
- vr.append( Version.emptyVersion.equals( floor ) ? "0" : floor.toString() );
+ vr.append(Version.emptyVersion.equals(floor) ? "0" : floor.toString());
}
else
{
- vr.append( openFloor ? "(" : "[" );
- String floorStr = Version.emptyVersion.equals( floor ) ? "0" : floor.toString();
+ vr.append(openFloor ? "(" : "[");
+ String floorStr = Version.emptyVersion.equals(floor) ? "0" : floor.toString();
String ceilingStr = ceiling.toString();
- vr.append( floorStr ).append( "," ).append( ceilingStr );
- vr.append( openCeiling ? ")" : "]" );
+ vr.append(floorStr).append(",").append(ceilingStr);
+ vr.append(openCeiling ? ")" : "]");
}
return vr.toString();
}
-
- public static VersionRange newInstance( Version pointVersion, VersionRangeBoundingRule lowerBoundRule,
- VersionRangeBoundingRule upperBoundRule )
+ public static VersionRange newInstance(Version pointVersion,
+ VersionRangeBoundingRule lowerBoundRule, VersionRangeBoundingRule upperBoundRule)
{
Version floor = null;
- switch ( lowerBoundRule )
+ switch (lowerBoundRule)
{
case Any:
- floor = VersionTable.getVersion( 0, 0, 0 );
+ floor = VersionTable.getVersion(0, 0, 0);
break;
case Major:
- floor = VersionTable.getVersion( pointVersion.getMajor(), 0, 0 );
+ floor = VersionTable.getVersion(pointVersion.getMajor(), 0, 0);
break;
case Minor:
- floor = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), 0 );
+ floor = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor(), 0);
break;
case Micro:
- floor = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), pointVersion.getMicro() );
+ floor = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor(), pointVersion.getMicro());
break;
case Exact:
floor = pointVersion;
@@ -278,19 +270,21 @@ public class VersionRange implements Ser
Version ceiling = null;
boolean openCeiling = true;
- switch ( upperBoundRule )
+ switch (upperBoundRule)
{
case Any:
ceiling = INFINITE_VERSION;
break;
case Major:
- ceiling = VersionTable.getVersion( pointVersion.getMajor() + 1, 0, 0 );
+ ceiling = VersionTable.getVersion(pointVersion.getMajor() + 1, 0, 0);
break;
case Minor:
- ceiling = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor() + 1, 0 );
+ ceiling = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor() + 1, 0);
break;
case Micro:
- ceiling = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), pointVersion.getMicro() + 1 );
+ ceiling = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor(), pointVersion.getMicro() + 1);
break;
case Exact:
ceiling = pointVersion;
@@ -298,6 +292,6 @@ public class VersionRange implements Ser
break;
}
- return new VersionRange( false, floor, ceiling, openCeiling );
+ return new VersionRange(false, floor, ceiling, openCeiling);
}
}
Modified: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java (original)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.osgi;
-
public enum VersionRangeBoundingRule
{
Exact, Micro, Minor, Major, Any
Modified: felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java (original)
+++ felix/trunk/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java Mon Aug 2 17:08:03 2010
@@ -33,40 +33,49 @@ import org.osgi.framework.Version;
public class VersionTable
{
private static final WeakHashMap<String, Version> versions = new WeakHashMap<String, Version>();
-
- public static Version getVersion(String version) {
- synchronized( versions ) {
+
+ public static Version getVersion(String version)
+ {
+ synchronized (versions)
+ {
Version v = versions.get(version);
- if ( v == null ) {
+ if (v == null)
+ {
v = Version.parseVersion(version);
versions.put(version, v);
}
-
+
return v;
}
}
-
- public static Version getVersion(int major, int minor, int micro) {
+
+ public static Version getVersion(int major, int minor, int micro)
+ {
return getVersion(major, minor, micro, null);
}
- public static Version getVersion(int major, int minor, int micro, String qualifier) {
+ public static Version getVersion(int major, int minor, int micro, String qualifier)
+ {
String key;
-
- if ( qualifier == null || qualifier.length() == 0 ) {
+
+ if (qualifier == null || qualifier.length() == 0)
+ {
key = major + "." + minor + "." + micro;
}
- else {
- key = major + "." + minor + "." + micro + "." + qualifier;
+ else
+ {
+ key = major + "." + minor + "." + micro + "." + qualifier;
}
-
- synchronized( versions ) {
+
+ synchronized (versions)
+ {
Version v = versions.get(key);
- if ( v == null ) {
+ if (v == null)
+ {
v = new Version(major, minor, micro, qualifier);
versions.put(key, v);
}
-
+
return v;
}
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java Mon Aug 2 17:08:03 2010
@@ -41,31 +41,34 @@ import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
public class BundleForm
-{
- public interface Resolver {
+{
+ public interface Resolver
+ {
URI[] resolve(URI base) throws URISyntaxException;
}
-
- public interface ResolutionContext {
+
+ public interface ResolutionContext
+ {
Resolver findResolver(URI uri);
}
-
- private static final Resolver NULL_RESOLVER = new Resolver() {
+
+ private static final Resolver NULL_RESOLVER = new Resolver()
+ {
public URI[] resolve(URI base)
{
return new URI[] { base };
}
-
+
};
private static final ResolutionContext NULL_CONTEXT = new ResolutionContext()
- {
+ {
public Resolver findResolver(URI uri)
{
return NULL_RESOLVER;
}
};
-
+
public static class BundleStatus
{
private String location;
@@ -73,99 +76,111 @@ public class BundleForm
private String version;
private long id;
private int status;
-
+
public String getLocation()
{
return location;
}
-
+
public void setLocation(String location)
{
this.location = location;
}
-
+
public String getBundleSymbolicName()
{
return bundleSymbolicName;
}
-
+
public void setBundleSymbolicName(String bundleSymbolicName)
{
this.bundleSymbolicName = bundleSymbolicName;
}
-
+
public String getVersion()
{
return version;
}
-
+
public void setVersion(String version)
{
this.version = version;
}
-
+
public long getId()
{
return id;
}
-
+
public void setId(long id)
{
this.id = id;
}
-
+
public void setStatus(int status)
{
this.status = status;
- }
-
- public int getStatus() {
+ }
+
+ public int getStatus()
+ {
return status;
}
public boolean isMatch(BundleStatus n)
{
- return bundleSymbolicName.equals( n.bundleSymbolicName ) && version.equals(n.version);
+ return bundleSymbolicName.equals(n.bundleSymbolicName)
+ && version.equals(n.version);
}
}
-
+
private URI[] bundles;
private Set<URI> startMap = new HashSet<URI>();
- public BundleForm() {
+ public BundleForm()
+ {
}
-
- public BundleStatus[] resolve(ResolutionContext ctx) throws IOException, URISyntaxException {
- if ( ctx == null ) {
+
+ public BundleStatus[] resolve(ResolutionContext ctx) throws IOException,
+ URISyntaxException
+ {
+ if (ctx == null)
+ {
ctx = NULL_CONTEXT;
}
-
+
ArrayList<BundleStatus> ret = new ArrayList<BundleStatus>(bundles.length);
-
- for ( int i = 0; i < bundles.length; i++ ) {
+
+ for (int i = 0; i < bundles.length; i++)
+ {
Resolver resolver = ctx.findResolver(bundles[i]);
- if ( resolver == null ) {
+ if (resolver == null)
+ {
resolver = NULL_RESOLVER;
}
URI[] resolved = resolver.resolve(bundles[i]);
- for ( URI uri : resolved ) {
+ for (URI uri : resolved)
+ {
BundleStatus bundle = toBundle(uri, isStarted(bundles[i]));
- if ( bundle == null ) {
+ if (bundle == null)
+ {
throw new IllegalStateException("Failed to read bundle " + uri);
}
- ret.add( bundle );
+ ret.add(bundle);
}
}
-
- return ret.toArray(new BundleStatus[ret.size()] );
+
+ return ret.toArray(new BundleStatus[ret.size()]);
}
-
+
private BundleStatus toBundle(URI uri, boolean started) throws IOException
{
- try {
+ try
+ {
Manifest mf = findManifest(uri);
- if ( mf == null ) return null;
+ if (mf == null)
+ return null;
Attributes attr = mf.getMainAttributes();
String bsn = attr.getValue(Constants.BUNDLE_SYMBOLICNAME);
String ver = attr.getValue(Constants.BUNDLE_VERSION);
@@ -176,7 +191,8 @@ public class BundleForm
st.setStatus(started ? Bundle.ACTIVE : Bundle.INSTALLED);
return st;
}
- catch (IllegalArgumentException e) {
+ catch (IllegalArgumentException e)
+ {
throw new IllegalArgumentException("Invalid uri " + uri, e);
}
}
@@ -185,71 +201,90 @@ public class BundleForm
{
Manifest mf = null;
- try {
+ try
+ {
File f = new File(uri);
- if ( f.isDirectory() ) {
- f = new File(f, "META-INF/MANIFEST.MF" );
- if ( f.isFile() ) {
+ if (f.isDirectory())
+ {
+ f = new File(f, "META-INF/MANIFEST.MF");
+ if (f.isFile())
+ {
FileInputStream fin = new FileInputStream(f);
- try {
+ try
+ {
mf = new Manifest(fin);
}
- finally {
+ finally
+ {
fin.close();
}
}
}
}
- catch (IllegalArgumentException e) {
+ catch (IllegalArgumentException e)
+ {
// fine
}
-
- if ( mf == null) {
+
+ if (mf == null)
+ {
InputStream in = uri.toURL().openStream();
- try {
+ try
+ {
JarInputStream jin = new JarInputStream(in);
mf = jin.getManifest();
- if ( mf == null ) {
- for(;;) {
+ if (mf == null)
+ {
+ for (;;)
+ {
JarEntry entry = jin.getNextJarEntry();
- if ( entry == null ) break;
- if ( "META-INF/MANIFEST.MF".equals(entry.getName()) ) {
+ if (entry == null)
+ break;
+ if ("META-INF/MANIFEST.MF".equals(entry.getName()))
+ {
mf = new Manifest(jin);
break;
}
}
}
-
+
}
- finally {
+ finally
+ {
in.close();
}
}
return mf;
}
- public static BundleForm create(URL formURL) throws IOException, URISyntaxException {
+ public static BundleForm create(URL formURL) throws IOException, URISyntaxException
+ {
InputStream in = formURL.openStream();
- try {
+ try
+ {
BundleForm f = new BundleForm();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
LinkedList<URI> locs = new LinkedList<URI>();
- for(;;) {
+ for (;;)
+ {
String l = r.readLine();
- if ( l == null ) break;
+ if (l == null)
+ break;
l = l.trim();
- if ( !l.startsWith( "#" ) ) {
+ if (!l.startsWith("#"))
+ {
URI uri = URI.create(l);
String status = uri.getScheme();
uri = URI.create(uri.getSchemeSpecificPart());
- locs.add( uri );
- f.setStarted(uri, "start".equalsIgnoreCase(status) );
+ locs.add(uri);
+ f.setStarted(uri, "start".equalsIgnoreCase(status));
}
}
f.setBundles(locs.toArray(new URI[locs.size()]));
return f;
}
- finally {
+ finally
+ {
try
{
in.close();
@@ -262,10 +297,11 @@ public class BundleForm
}
}
- public void setBundles(URI[] bundles) {
+ public void setBundles(URI[] bundles)
+ {
this.bundles = bundles;
}
-
+
public URI[] getBundles()
{
return bundles;
@@ -275,13 +311,16 @@ public class BundleForm
{
return startMap.contains(uri);
}
-
- public void setStarted(URI uri, boolean started) {
- if ( started ) {
+
+ public void setStarted(URI uri, boolean started)
+ {
+ if (started)
+ {
startMap.add(uri);
}
- else {
+ else
+ {
startMap.remove(uri);
}
- }
+ }
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -43,7 +42,6 @@ import org.osgi.framework.BundleExceptio
import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
import static org.apache.felix.sigil.common.runtime.Runtime.ADDRESS_PROPERTY;
-
/**
* @author dave
*
@@ -54,36 +52,37 @@ public class Client
private DataInputStream in;
private DataOutputStream out;
-
public Client()
{
}
-
+
public void connect(Properties props) throws IOException
{
- String v = props.getProperty( ADDRESS_PROPERTY );
- InetAddress address = v == null ? null : InetAddress.getByName( v );
- int port = Integer.parseInt( props.getProperty( PORT_PROPERTY, "0" ) );
-
- if ( port < 1 ) {
- throw new IOException( "Missing or invalid port" );
+ String v = props.getProperty(ADDRESS_PROPERTY);
+ InetAddress address = v == null ? null : InetAddress.getByName(v);
+ int port = Integer.parseInt(props.getProperty(PORT_PROPERTY, "0"));
+
+ if (port < 1)
+ {
+ throw new IOException("Missing or invalid port");
}
-
+
InetSocketAddress endpoint = new InetSocketAddress(address, port);
-
+
socket = new Socket();
- socket.connect( endpoint );
-
- Main.log( "Connected to " + endpoint );
-
- in = new DataInputStream( socket.getInputStream() );
- out = new DataOutputStream( socket.getOutputStream() );
+ socket.connect(endpoint);
+
+ Main.log("Connected to " + endpoint);
+
+ in = new DataInputStream(socket.getInputStream());
+ out = new DataOutputStream(socket.getOutputStream());
}
- public boolean isConnected() {
+ public boolean isConnected()
+ {
return socket != null;
}
-
+
public void disconnect() throws IOException
{
socket.close();
@@ -92,148 +91,174 @@ public class Client
out = null;
}
- public void apply(BundleForm.BundleStatus[] newStatus) throws IOException, BundleException {
+ public void apply(BundleForm.BundleStatus[] newStatus) throws IOException,
+ BundleException
+ {
BundleStatus[] currentStatus = status();
-
+
stopOldBundles(currentStatus, newStatus);
-
+
boolean change = uninstallOldBundles(currentStatus, newStatus);
change |= installNewBundles(currentStatus, newStatus);
-
- if ( change )
+
+ if (change)
refresh();
-
+
startNewBundles(newStatus);
}
public void refresh() throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new RefreshAction( in, out ).client();
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new RefreshAction(in, out).client();
}
- public long install( String url ) throws IOException, BundleException
+ public long install(String url) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- return new InstallAction( in, out ).client( url );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ return new InstallAction(in, out).client(url);
}
-
- public void start( long bundle ) throws IOException, BundleException
+ public void start(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new StartAction( in, out ).client( bundle );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new StartAction(in, out).client(bundle);
}
-
- public void stop( long bundle ) throws IOException, BundleException
+ public void stop(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new StopAction( in, out ).client( bundle );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new StopAction(in, out).client(bundle);
}
-
- public void uninstall( long bundle ) throws IOException, BundleException
+ public void uninstall(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new UninstallAction( in, out ).client( bundle );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new UninstallAction(in, out).client(bundle);
}
-
- public void update( long bundle ) throws IOException, BundleException
+ public void update(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
Update update = new UpdateAction.Update(bundle, null);
- new UpdateAction( in, out ).client(update);
+ new UpdateAction(in, out).client(update);
}
-
- public void update( long bundle, String url ) throws IOException, BundleException
+ public void update(long bundle, String url) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
Update update = new UpdateAction.Update(bundle, url);
- new UpdateAction( in, out ).client(update);
+ new UpdateAction(in, out).client(update);
}
-
public BundleStatus[] status() throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- return new StatusAction( in, out ).client();
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ return new StatusAction(in, out).client();
}
-
- private boolean installNewBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+
+ private boolean installNewBundles(BundleStatus[] status, BundleStatus[] newStatus)
+ throws IOException, BundleException
{
boolean change = false;
- for (BundleStatus n : newStatus) {
+ for (BundleStatus n : newStatus)
+ {
boolean found = false;
- for ( BundleStatus o : status ) {
- if ( o.isMatch(n) ) {
+ for (BundleStatus o : status)
+ {
+ if (o.isMatch(n))
+ {
update(o.getId(), n.getLocation());
found = true;
change = true;
break;
}
}
-
- if ( !found ) {
+
+ if (!found)
+ {
install(n.getLocation());
change = true;
}
}
-
+
return change;
}
- private void startNewBundles(BundleStatus[] newStatus) throws IOException, BundleException
+ private void startNewBundles(BundleStatus[] newStatus) throws IOException,
+ BundleException
{
BundleStatus[] status = status();
- for (BundleStatus n : newStatus) {
- if ( n.getStatus() == Bundle.ACTIVE ) {
- for ( BundleStatus o : status ) {
- if ( o.isMatch(n) ) {
+ for (BundleStatus n : newStatus)
+ {
+ if (n.getStatus() == Bundle.ACTIVE)
+ {
+ for (BundleStatus o : status)
+ {
+ if (o.isMatch(n))
+ {
start(o.getId());
}
}
- }
+ }
}
}
- private void stopOldBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+ private void stopOldBundles(BundleStatus[] status, BundleStatus[] newStatus)
+ throws IOException, BundleException
{
- for (BundleStatus n : newStatus) {
- if ( n.getStatus() == Bundle.INSTALLED ) {
- for ( BundleStatus o : status ) {
- if ( o.getId() != 0 ) {
- if ( o.isMatch(n) ) {
+ for (BundleStatus n : newStatus)
+ {
+ if (n.getStatus() == Bundle.INSTALLED)
+ {
+ for (BundleStatus o : status)
+ {
+ if (o.getId() != 0)
+ {
+ if (o.isMatch(n))
+ {
stop(o.getId());
- }
+ }
}
}
- }
+ }
}
}
- private boolean uninstallOldBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+ private boolean uninstallOldBundles(BundleStatus[] status, BundleStatus[] newStatus)
+ throws IOException, BundleException
{
boolean change = false;
- for ( BundleStatus o : status ) {
- if ( o.getId() != 0 ) {
+ for (BundleStatus o : status)
+ {
+ if (o.getId() != 0)
+ {
boolean found = false;
-
- for (BundleStatus n : newStatus) {
- if ( o.isMatch(n) ) {
+
+ for (BundleStatus n : newStatus)
+ {
+ if (o.isMatch(n))
+ {
found = true;
break;
}
}
-
- if ( !found ) {
+
+ if (!found)
+ {
change = true;
uninstall(o.getId());
}
}
}
return change;
- }
+ }
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime;
-
import static org.apache.felix.sigil.common.runtime.Runtime.ADDRESS_PROPERTY;
import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
@@ -42,89 +41,88 @@ import org.osgi.framework.BundleExceptio
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
-
public class Main
{
private static final String COMMAND_LINE_SYNTAX = "java -jar org.apache.felix.sigil.common.runtime";
private static Framework framework;
private static final Options options;
-
+
private static boolean verbose = false;
static
{
options = new Options();
- options.addOption( "?", "help", false, "Print help for the Sigil launcher" );
- options.addOption( "p", "port", true, "Port to launch server on (0 implies auto allocate) [default 0]" );
- options.addOption( "a", "address", true, "Address to bind server to [default all]" );
- options.addOption( "c", "clean", false, "Clean bundle cache directory on init" );
- options.addOption( "s", "startLevel", true, "Start level for framework" );
- options.addOption( "v", "verbose", false, "Verbose output" );
+ options.addOption("?", "help", false, "Print help for the Sigil launcher");
+ options.addOption("p", "port", true,
+ "Port to launch server on (0 implies auto allocate) [default 0]");
+ options.addOption("a", "address", true, "Address to bind server to [default all]");
+ options.addOption("c", "clean", false, "Clean bundle cache directory on init");
+ options.addOption("s", "startLevel", true, "Start level for framework");
+ options.addOption("v", "verbose", false, "Verbose output");
}
-
- public static void main( String[] args ) throws Exception
+ public static void main(String[] args) throws Exception
{
FrameworkFactory factory = getFrameworkFactory();
try
{
Parser parser = new PosixParser();
- CommandLine cl = parser.parse( options, args );
+ CommandLine cl = parser.parse(options, args);
- if ( cl.hasOption( '?' ) )
+ if (cl.hasOption('?'))
{
printHelp();
}
else
{
verbose = cl.hasOption('v');
-
- Map<String, String> config = buildConfig( cl );
- framework = factory.newFramework( config );
+ Map<String, String> config = buildConfig(cl);
+
+ framework = factory.newFramework(config);
framework.init();
framework.start();
- Server server = launch( cl );
+ Server server = launch(cl);
- framework.waitForStop( 0 );
+ framework.waitForStop(0);
- if ( server != null )
+ if (server != null)
{
server.stop();
}
}
}
- catch ( NoSuchElementException e )
+ catch (NoSuchElementException e)
{
- System.err.println( "No " + FrameworkFactory.class.getName() + " found on classpath" );
- System.exit( 1 );
+ System.err.println("No " + FrameworkFactory.class.getName()
+ + " found on classpath");
+ System.exit(1);
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
- System.err.println( "Interrupted prior to framework stop" );
- System.exit( 1 );
+ System.err.println("Interrupted prior to framework stop");
+ System.exit(1);
}
- catch ( ParseException e )
+ catch (ParseException e)
{
printHelp();
- System.exit( 1 );
+ System.exit(1);
}
- catch ( BundleException e )
+ catch (BundleException e)
{
e.printStackTrace();
- System.exit( 1 );
+ System.exit(1);
}
- catch ( IOException e )
+ catch (IOException e)
{
e.printStackTrace();
- System.exit( 1 );
+ System.exit(1);
}
}
-
/**
* Simple method to parse META-INF/services file for framework factory.
* Currently, it assumes the first non-commented line is the class name
@@ -135,65 +133,64 @@ public class Main
private static FrameworkFactory getFrameworkFactory() throws Exception
{
URL url = Main.class.getClassLoader().getResource(
- "META-INF/services/org.osgi.framework.launch.FrameworkFactory" );
- if ( url != null )
+ "META-INF/services/org.osgi.framework.launch.FrameworkFactory");
+ if (url != null)
{
- BufferedReader br = new BufferedReader( new InputStreamReader( url.openStream() ) );
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader(url.openStream()));
try
{
- for ( String s = br.readLine(); s != null; s = br.readLine() )
+ for (String s = br.readLine(); s != null; s = br.readLine())
{
s = s.trim();
// Try to load first non-empty, non-commented line.
- if ( ( s.length() > 0 ) && ( s.charAt( 0 ) != '#' ) )
+ if ((s.length() > 0) && (s.charAt(0) != '#'))
{
- return ( FrameworkFactory ) Class.forName( s ).newInstance();
+ return (FrameworkFactory) Class.forName(s).newInstance();
}
}
}
finally
{
- if ( br != null )
+ if (br != null)
br.close();
}
}
- throw new Exception( "Could not find framework factory." );
+ throw new Exception("Could not find framework factory.");
}
-
- private static Map<String, String> buildConfig( CommandLine cl )
+ private static Map<String, String> buildConfig(CommandLine cl)
{
HashMap<String, String> config = new HashMap<String, String>();
- if ( cl.hasOption( 'c' ))
- config.put( "org.osgi.framework.storage.clean", "onFirstInit" );
-
- if ( cl.hasOption( 's' ) )
- config.put( "org.osgi.framework.startlevel.beginning", cl.getOptionValue( 's' ) );
-
+ if (cl.hasOption('c'))
+ config.put("org.osgi.framework.storage.clean", "onFirstInit");
+
+ if (cl.hasOption('s'))
+ config.put("org.osgi.framework.startlevel.beginning", cl.getOptionValue('s'));
+
return config;
}
-
- private static Server launch( CommandLine line ) throws IOException
+ private static Server launch(CommandLine line) throws IOException
{
- Server server = new Server( framework );
+ Server server = new Server(framework);
Properties props = new Properties();
- props.put( ADDRESS_PROPERTY, line.getOptionValue( 'a' ) );
- props.put( PORT_PROPERTY, line.getOptionValue( 'p' ) );
- server.start( props );
+ props.put(ADDRESS_PROPERTY, line.getOptionValue('a'));
+ props.put(PORT_PROPERTY, line.getOptionValue('p'));
+ server.start(props);
return server;
}
-
private static void printHelp()
{
HelpFormatter f = new HelpFormatter();
- f.printHelp( COMMAND_LINE_SYNTAX, options );
+ f.printHelp(COMMAND_LINE_SYNTAX, options);
}
-
- public static void log(String msg) {
- if ( verbose )
- System.out.println( msg );
+
+ public static void log(String msg)
+ {
+ if (verbose)
+ System.out.println(msg);
}
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java Mon Aug 2 17:08:03 2010
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
@@ -47,7 +46,6 @@ import static org.apache.felix.sigil.com
import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
import static org.apache.felix.sigil.common.runtime.io.Constants.*;
-
/**
* @author dave
*
@@ -60,54 +58,52 @@ public class Server
private AtomicBoolean stopped = new AtomicBoolean();
-
- public Server( Framework fw )
+ public Server(Framework fw)
{
this.fw = fw;
}
-
- public void start( Properties props ) throws IOException
+ public void start(Properties props) throws IOException
{
final ServerSocket socket = new ServerSocket();
-
- String v = props.getProperty( ADDRESS_PROPERTY );
- InetAddress address = v == null ? null : InetAddress.getByName( v );
- int port = Integer.parseInt( props.getProperty( PORT_PROPERTY, "0" ) );
-
- InetSocketAddress socketAddress = new InetSocketAddress(address, port);
- socket.bind( socketAddress );
-
- Main.log( "Started server listening on " + socket.getLocalSocketAddress() + ":" + socket.getLocalPort() );
-
- accept = new Thread( new Runnable()
+
+ String v = props.getProperty(ADDRESS_PROPERTY);
+ InetAddress address = v == null ? null : InetAddress.getByName(v);
+ int port = Integer.parseInt(props.getProperty(PORT_PROPERTY, "0"));
+
+ InetSocketAddress socketAddress = new InetSocketAddress(address, port);
+ socket.bind(socketAddress);
+
+ Main.log("Started server listening on " + socket.getLocalSocketAddress() + ":"
+ + socket.getLocalPort());
+
+ accept = new Thread(new Runnable()
{
public void run()
{
- while ( !stopped.get() )
+ while (!stopped.get())
{
try
{
- read.execute( new Reader( socket.accept() ) );
+ read.execute(new Reader(socket.accept()));
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
- } );
-
+ });
+
accept.start();
-
- Main.log( "Started thread!" );
- }
+ Main.log("Started thread!");
+ }
public void stop()
{
- stopped.set( true );
+ stopped.set(true);
accept.interrupt();
accept = null;
}
@@ -117,81 +113,83 @@ public class Server
private final Socket socket;
-
/**
* @param accept
*/
- public Reader( Socket socket )
+ public Reader(Socket socket)
{
this.socket = socket;
}
-
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run()
{
- Main.log( "Accepted " + socket.getInetAddress() + ":" + socket.getLocalPort() );
-
+ Main.log("Accepted " + socket.getInetAddress() + ":" + socket.getLocalPort());
+
try
{
- DataInputStream in = new DataInputStream( socket.getInputStream() );
- DataOutputStream out = new DataOutputStream( socket.getOutputStream() );
-
- while ( !stopped.get() )
+ DataInputStream in = new DataInputStream(socket.getInputStream());
+ DataOutputStream out = new DataOutputStream(socket.getOutputStream());
+
+ while (!stopped.get())
{
int action = in.readInt();
-
+
Action<?, ?> task = null;
-
- switch ( action )
+
+ switch (action)
{
case INSTALL:
- task = new InstallAction( in, out );
+ task = new InstallAction(in, out);
break;
case START:
- task = new StartAction( in, out );
+ task = new StartAction(in, out);
break;
case STOP:
- task = new StopAction( in, out );
+ task = new StopAction(in, out);
break;
case UNINSTALL:
- task = new UninstallAction( in, out );
+ task = new UninstallAction(in, out);
break;
case UPDATE:
- task = new UpdateAction( in, out );
+ task = new UpdateAction(in, out);
break;
case STATUS:
- task = new StatusAction( in, out );
+ task = new StatusAction(in, out);
break;
case REFRESH:
task = new RefreshAction(in, out);
break;
}
-
- if ( task == null ) {
- Main.log( "Invalid action " + action );
+
+ if (task == null)
+ {
+ Main.log("Invalid action " + action);
}
- else {
- task.server( fw );
+ else
+ {
+ task.server(fw);
}
}
}
- catch ( EOFException e ) {
+ catch (EOFException e)
+ {
// fine
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
- finally {
+ finally
+ {
try
{
socket.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java Mon Aug 2 17:08:03 2010
@@ -53,8 +53,9 @@ public class AlreadySelectedException ex
*/
public AlreadySelectedException(OptionGroup group, Option option)
{
- this("The option '" + option.getKey() + "' was specified but an option from this group "
- + "has already been selected: '" + group.getSelected() + "'");
+ this("The option '" + option.getKey()
+ + "' was specified but an option from this group "
+ + "has already been selected: '" + group.getSelected() + "'");
this.group = group;
this.option = option;
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java Mon Aug 2 17:08:03 2010
@@ -39,7 +39,8 @@ public class BasicParser extends Parser
* when an non option is found.
* @return The <code>arguments</code> String array.
*/
- protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+ protected String[] flatten(Options options, String[] arguments,
+ boolean stopAtNonOption)
{
// just echo the arguments
return arguments;
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java Mon Aug 2 17:08:03 2010
@@ -89,11 +89,14 @@ public class CommandLine implements Seri
*/
public Object getOptionObject(String opt)
{
- try {
+ try
+ {
return getParsedOptionValue(opt);
- } catch(ParseException pe) {
- System.err.println("Exception found converting " + opt + " to desired type: " +
- pe.getMessage() );
+ }
+ catch (ParseException pe)
+ {
+ System.err.println("Exception found converting " + opt + " to desired type: "
+ + pe.getMessage());
return null;
}
}
@@ -106,8 +109,7 @@ public class CommandLine implements Seri
* @throws ParseException if there are problems turning the option value into the desired type
* @see PatternOptionBuilder
*/
- public Object getParsedOptionValue(String opt)
- throws ParseException
+ public Object getParsedOptionValue(String opt) throws ParseException
{
String res = getOptionValue(opt);
@@ -119,7 +121,7 @@ public class CommandLine implements Seri
Object type = option.getType();
- return (res == null) ? null : TypeHandler.createValue(res, type);
+ return (res == null) ? null : TypeHandler.createValue(res, type);
}
/**
@@ -179,7 +181,8 @@ public class CommandLine implements Seri
}
}
- return values.isEmpty() ? null : (String[]) values.toArray(new String[values.size()]);
+ return values.isEmpty() ? null
+ : (String[]) values.toArray(new String[values.size()]);
}
/**
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java Mon Aug 2 17:08:03 2010
@@ -70,7 +70,8 @@ public interface CommandLineParser
* @throws ParseException if there are any problems encountered
* while parsing the command line tokens.
*/
- CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException;
+ CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
+ throws ParseException;
/**
* Parse the arguments according to the specified options and
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java Mon Aug 2 17:08:03 2010
@@ -46,7 +46,8 @@ public class GnuParser extends Parser
* a non option has been encountered
* @return a String array of the flattened arguments
*/
- protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+ protected String[] flatten(Options options, String[] arguments,
+ boolean stopAtNonOption)
{
List tokens = new ArrayList();
@@ -75,7 +76,8 @@ public class GnuParser extends Parser
}
else
{
- if (opt.indexOf('=') != -1 && options.hasOption(opt.substring(0, opt.indexOf('='))))
+ if (opt.indexOf('=') != -1
+ && options.hasOption(opt.substring(0, opt.indexOf('='))))
{
// the format is --foo=value or -foo=value
tokens.add(arg.substring(0, arg.indexOf('='))); // --foo
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java Mon Aug 2 17:08:03 2010
@@ -359,7 +359,8 @@ public class HelpFormatter
* @param options the Options instance
* @param footer the banner to display at the end of the help
*/
- public void printHelp(String cmdLineSyntax, String header, Options options, String footer)
+ public void printHelp(String cmdLineSyntax, String header, Options options,
+ String footer)
{
printHelp(cmdLineSyntax, header, options, footer, false);
}
@@ -376,7 +377,8 @@ public class HelpFormatter
* @param autoUsage whether to print an automatically generated
* usage statement
*/
- public void printHelp(String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
+ public void printHelp(String cmdLineSyntax, String header, Options options,
+ String footer, boolean autoUsage)
{
printHelp(defaultWidth, cmdLineSyntax, header, options, footer, autoUsage);
}
@@ -392,7 +394,8 @@ public class HelpFormatter
* @param options the Options instance
* @param footer the banner to display at the end of the help
*/
- public void printHelp(int width, String cmdLineSyntax, String header, Options options, String footer)
+ public void printHelp(int width, String cmdLineSyntax, String header,
+ Options options, String footer)
{
printHelp(width, cmdLineSyntax, header, options, footer, false);
}
@@ -411,11 +414,12 @@ public class HelpFormatter
* usage statement
*/
public void printHelp(int width, String cmdLineSyntax, String header,
- Options options, String footer, boolean autoUsage)
+ Options options, String footer, boolean autoUsage)
{
PrintWriter pw = new PrintWriter(System.out);
- printHelp(pw, width, cmdLineSyntax, header, options, defaultLeftPad, defaultDescPad, footer, autoUsage);
+ printHelp(pw, width, cmdLineSyntax, header, options, defaultLeftPad,
+ defaultDescPad, footer, autoUsage);
pw.flush();
}
@@ -436,14 +440,13 @@ public class HelpFormatter
*
* @throws IllegalStateException if there is no room to print a line
*/
- public void printHelp(PrintWriter pw, int width, String cmdLineSyntax,
- String header, Options options, int leftPad,
- int descPad, String footer)
+ public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header,
+ Options options, int leftPad, int descPad, String footer)
{
- printHelp(pw, width, cmdLineSyntax, header, options, leftPad, descPad, footer, false);
+ printHelp(pw, width, cmdLineSyntax, header, options, leftPad, descPad, footer,
+ false);
}
-
/**
* Print the help for <code>options</code> with the specified
* command line syntax.
@@ -463,9 +466,8 @@ public class HelpFormatter
*
* @throws IllegalStateException if there is no room to print a line
*/
- public void printHelp(PrintWriter pw, int width, String cmdLineSyntax,
- String header, Options options, int leftPad,
- int descPad, String footer, boolean autoUsage)
+ public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header,
+ Options options, int leftPad, int descPad, String footer, boolean autoUsage)
{
if ((cmdLineSyntax == null) || (cmdLineSyntax.length() == 0))
{
@@ -534,7 +536,6 @@ public class HelpFormatter
// add the group to the processed list
processedGroups.add(group);
-
// add the usage clause
appendOptionGroup(buff, group);
}
@@ -555,7 +556,6 @@ public class HelpFormatter
}
}
-
// call printWrapped
printWrapped(pw, width, buff.toString().indexOf(' ') + 1, buff.toString());
}
@@ -602,7 +602,8 @@ public class HelpFormatter
* @param option the Option to append
* @param required whether the Option is required or not
*/
- private static void appendOption(final StringBuffer buff, final Option option, final boolean required)
+ private static void appendOption(final StringBuffer buff, final Option option,
+ final boolean required)
{
if (!required)
{
@@ -643,7 +644,8 @@ public class HelpFormatter
{
int argPos = cmdLineSyntax.indexOf(' ') + 1;
- printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos, defaultSyntaxPrefix + cmdLineSyntax);
+ printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos,
+ defaultSyntaxPrefix + cmdLineSyntax);
}
/**
@@ -658,8 +660,8 @@ public class HelpFormatter
* @param descPad the number of characters of padding to be prefixed
* to each description line
*/
- public void printOptions(PrintWriter pw, int width, Options options,
- int leftPad, int descPad)
+ public void printOptions(PrintWriter pw, int width, Options options, int leftPad,
+ int descPad)
{
StringBuffer sb = new StringBuffer();
@@ -711,7 +713,8 @@ public class HelpFormatter
*
* @return the StringBuffer with the rendered Options contents.
*/
- protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad)
+ protected StringBuffer renderOptions(StringBuffer sb, int width, Options options,
+ int leftPad, int descPad)
{
final String lpad = createPadding(leftPad);
final String dpad = createPadding(descPad);
@@ -735,7 +738,8 @@ public class HelpFormatter
if (option.getOpt() == null)
{
- optBuf.append(lpad).append(" " + defaultLongOptPrefix).append(option.getLongOpt());
+ optBuf.append(lpad).append(" " + defaultLongOptPrefix).append(
+ option.getLongOpt());
}
else
{
@@ -743,7 +747,8 @@ public class HelpFormatter
if (option.hasLongOpt())
{
- optBuf.append(',').append(defaultLongOptPrefix).append(option.getLongOpt());
+ optBuf.append(',').append(defaultLongOptPrefix).append(
+ option.getLongOpt());
}
}
@@ -806,8 +811,8 @@ public class HelpFormatter
*
* @return the StringBuffer with the rendered Options contents.
*/
- protected StringBuffer renderWrappedText(StringBuffer sb, int width,
- int nextLineTabStop, String text)
+ protected StringBuffer renderWrappedText(StringBuffer sb, int width,
+ int nextLineTabStop, String text)
{
int pos = findWrapPos(text, width, 0);
@@ -840,8 +845,8 @@ public class HelpFormatter
return sb;
}
-
- if ( (text.length() > width) && (pos == nextLineTabStop - 1) )
+
+ if ((text.length() > width) && (pos == nextLineTabStop - 1))
{
pos = width;
}
@@ -869,7 +874,7 @@ public class HelpFormatter
// the line ends before the max wrap pos or a new line char found
if (((pos = text.indexOf('\n', startPos)) != -1 && pos <= width)
- || ((pos = text.indexOf('\t', startPos)) != -1 && pos <= width))
+ || ((pos = text.indexOf('\t', startPos)) != -1 && pos <= width))
{
return pos + 1;
}
@@ -878,14 +883,13 @@ public class HelpFormatter
return -1;
}
-
// look for the last whitespace character before startPos+width
pos = startPos + width;
char c;
- while ((pos >= startPos) && ((c = text.charAt(pos)) != ' ')
- && (c != '\n') && (c != '\r'))
+ while ((pos >= startPos) && ((c = text.charAt(pos)) != ' ') && (c != '\n')
+ && (c != '\r'))
{
--pos;
}
@@ -895,13 +899,13 @@ public class HelpFormatter
{
return pos;
}
-
+
// must look for the first whitespace chearacter after startPos
// + width
pos = startPos + width;
- while ((pos <= text.length()) && ((c = text.charAt(pos)) != ' ')
- && (c != '\n') && (c != '\r'))
+ while ((pos <= text.length()) && ((c = text.charAt(pos)) != ' ') && (c != '\n')
+ && (c != '\r'))
{
++pos;
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java Mon Aug 2 17:08:03 2010
@@ -116,8 +116,7 @@ public class Option implements Cloneable
* @throws IllegalArgumentException if there are any non valid
* Option characters in <code>opt</code>.
*/
- public Option(String opt, String longOpt, boolean hasArg, String description)
- throws IllegalArgumentException
+ public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException
{
// ensure that the option is valid
OptionValidator.validateOption(opt);
@@ -529,7 +528,8 @@ public class Option implements Cloneable
*/
public String[] getValues()
{
- return hasNoValues() ? null : (String[]) values.toArray(new String[values.size()]);
+ return hasNoValues() ? null
+ : (String[]) values.toArray(new String[values.size()]);
}
/**
@@ -603,7 +603,6 @@ public class Option implements Cloneable
Option option = (Option) o;
-
if (opt != null ? !opt.equals(option.opt) : option.opt != null)
{
return false;
@@ -644,7 +643,8 @@ public class Option implements Cloneable
}
catch (CloneNotSupportedException cnse)
{
- throw new RuntimeException("A CloneNotSupportedException was thrown: " + cnse.getMessage());
+ throw new RuntimeException("A CloneNotSupportedException was thrown: "
+ + cnse.getMessage());
}
}
@@ -667,7 +667,8 @@ public class Option implements Cloneable
*/
public boolean addValue(String value)
{
- throw new UnsupportedOperationException("The addValue method is not intended for client use. "
+ throw new UnsupportedOperationException(
+ "The addValue method is not intended for client use. "
+ "Subclasses should use the addValueForProcessing method instead. ");
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java Mon Aug 2 17:08:03 2010
@@ -77,7 +77,6 @@ public final class OptionBuilder
required = false;
numberOfArgs = Option.UNINITIALIZED;
-
// PMM 9/6/02 - these were missing
optionalArg = false;
valuesep = (char) 0;
@@ -346,7 +345,8 @@ public final class OptionBuilder
public static Option create(String opt) throws IllegalArgumentException
{
Option option = null;
- try {
+ try
+ {
// create the option
option = new Option(opt, description);
@@ -358,7 +358,9 @@ public final class OptionBuilder
option.setType(type);
option.setValueSeparator(valuesep);
option.setArgName(argName);
- } finally {
+ }
+ finally
+ {
// reset the OptionBuilder properties
OptionBuilder.reset();
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java Mon Aug 2 17:08:03 2010
@@ -32,7 +32,7 @@ import java.util.Map;
public class OptionGroup implements Serializable
{
private static final long serialVersionUID = 1L;
-
+
/** hold the options */
private Map optionMap = new HashMap();
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java Mon Aug 2 17:08:03 2010
@@ -70,7 +70,8 @@ class OptionValidator
{
if (!isValidChar(chars[i]))
{
- throw new IllegalArgumentException("opt contains illegal character value '" + chars[i] + "'");
+ throw new IllegalArgumentException(
+ "opt contains illegal character value '" + chars[i] + "'");
}
}
}
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java Mon Aug 2 17:08:03 2010
@@ -126,7 +126,8 @@ public class Options implements Serializ
* @param description Self-documenting description
* @return the resulting Options instance
*/
- public Options addOption(String opt, String longOpt, boolean hasArg, String description)
+ public Options addOption(String opt, String longOpt, boolean hasArg,
+ String description)
{
addOption(new Option(opt, longOpt, hasArg, description));
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java Mon Aug 2 17:08:03 2010
@@ -68,7 +68,8 @@ public abstract class Parser implements
* flattening when a non option has been encountered
* @return a String array of the flattened arguments
*/
- protected abstract String[] flatten(Options opts, String[] arguments, boolean stopAtNonOption);
+ protected abstract String[] flatten(Options opts, String[] arguments,
+ boolean stopAtNonOption);
/**
* Parses the specified <code>arguments</code> based
@@ -97,7 +98,8 @@ public abstract class Parser implements
*
* @since 1.1
*/
- public CommandLine parse(Options options, String[] arguments, Properties properties) throws ParseException
+ public CommandLine parse(Options options, String[] arguments, Properties properties)
+ throws ParseException
{
return parse(options, arguments, properties, false);
}
@@ -114,7 +116,8 @@ public abstract class Parser implements
* @return the <code>CommandLine</code>
* @throws ParseException if an error occurs when parsing the arguments.
*/
- public CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException
+ public CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
+ throws ParseException
{
return parse(options, arguments, null, stopAtNonOption);
}
@@ -136,8 +139,8 @@ public abstract class Parser implements
*
* @since 1.1
*/
- public CommandLine parse(Options options, String[] arguments, Properties properties, boolean stopAtNonOption)
- throws ParseException
+ public CommandLine parse(Options options, String[] arguments, Properties properties,
+ boolean stopAtNonOption) throws ParseException
{
// clear out the data in options in case it's been used before (CLI-71)
for (Iterator it = options.helpOptions().iterator(); it.hasNext();)
@@ -271,8 +274,7 @@ public abstract class Parser implements
}
}
else if (!("yes".equalsIgnoreCase(value)
- || "true".equalsIgnoreCase(value)
- || "1".equalsIgnoreCase(value)))
+ || "true".equalsIgnoreCase(value) || "1".equalsIgnoreCase(value)))
{
// if the value is not yes, true or 1 then don't add the
// option to the CommandLine
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java Mon Aug 2 17:08:03 2010
@@ -127,16 +127,8 @@ public class PatternOptionBuilder
*/
public static boolean isValueCode(char ch)
{
- return ch == '@'
- || ch == ':'
- || ch == '%'
- || ch == '+'
- || ch == '#'
- || ch == '<'
- || ch == '>'
- || ch == '*'
- || ch == '/'
- || ch == '!';
+ return ch == '@' || ch == ':' || ch == '%' || ch == '+' || ch == '#' || ch == '<'
+ || ch == '>' || ch == '*' || ch == '/' || ch == '!';
}
/**
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java Mon Aug 2 17:08:03 2010
@@ -92,7 +92,8 @@ public class PosixParser extends Parser
* when an non option is found.
* @return The flattened <code>arguments</code> String array.
*/
- protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+ protected String[] flatten(Options options, String[] arguments,
+ boolean stopAtNonOption)
{
init();
this.options = options;
@@ -119,7 +120,7 @@ public class PosixParser extends Parser
else
{
currentOption = options.getOption(opt);
-
+
tokens.add(opt);
if (pos != -1)
{
Modified: felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java?rev=981604&r1=981603&r2=981604&view=diff
==============================================================================
--- felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java (original)
+++ felix/trunk/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java Mon Aug 2 17:08:03 2010
@@ -43,8 +43,7 @@ public class TypeHandler
* @return The instance of <code>obj</code> initialised with
* the value of <code>str</code>.
*/
- public static Object createValue(String str, Object obj)
- throws ParseException
+ public static Object createValue(String str, Object obj) throws ParseException
{
return createValue(str, (Class) obj);
}
@@ -58,8 +57,7 @@ public class TypeHandler
* @return The instance of <code>clazz</code> initialised with
* the value of <code>str</code>.
*/
- public static Object createValue(String str, Class clazz)
- throws ParseException
+ public static Object createValue(String str, Class clazz) throws ParseException
{
if (PatternOptionBuilder.STRING_VALUE == clazz)
{
@@ -110,8 +108,7 @@ public class TypeHandler
* @return the initialised object, or null if it couldn't create
* the Object.
*/
- public static Object createObject(String classname)
- throws ParseException
+ public static Object createObject(String classname) throws ParseException
{
Class cl = null;
@@ -132,7 +129,8 @@ public class TypeHandler
}
catch (Exception e)
{
- throw new ParseException(e.getClass().getName() + "; Unable to create an instance of: " + classname);
+ throw new ParseException(e.getClass().getName()
+ + "; Unable to create an instance of: " + classname);
}
return instance;
@@ -146,8 +144,7 @@ public class TypeHandler
* @return the number represented by <code>str</code>, if <code>str</code>
* is not a number, null is returned.
*/
- public static Number createNumber(String str)
- throws ParseException
+ public static Number createNumber(String str) throws ParseException
{
try
{
@@ -172,8 +169,7 @@ public class TypeHandler
* @param classname the class name
* @return The class if it is found, otherwise return null
*/
- public static Class createClass(String classname)
- throws ParseException
+ public static Class createClass(String classname) throws ParseException
{
try
{
@@ -192,8 +188,7 @@ public class TypeHandler
* @return The date if <code>str</code> is a valid date string,
* otherwise return null.
*/
- public static Date createDate(String str)
- throws ParseException
+ public static Date createDate(String str) throws ParseException
{
throw new UnsupportedOperationException("Not yet implemented");
}
@@ -205,8 +200,7 @@ public class TypeHandler
* @return The URL is <code>str</code> is well-formed, otherwise
* return null.
*/
- public static URL createURL(String str)
- throws ParseException
+ public static URL createURL(String str) throws ParseException
{
try
{
@@ -224,8 +218,7 @@ public class TypeHandler
* @param str the File location
* @return The file represented by <code>str</code>.
*/
- public static File createFile(String str)
- throws ParseException
+ public static File createFile(String str) throws ParseException
{
return new File(str);
}
@@ -236,8 +229,7 @@ public class TypeHandler
* @param str the paths to the files
* @return The File[] represented by <code>str</code>.
*/
- public static File[] createFiles(String str)
- throws ParseException
+ public static File[] createFiles(String str) throws ParseException
{
// to implement/port:
// return FileW.findFiles(str);
|