Skip to content

Commit

Permalink
[all] Remove strings as much as possible.
Browse files Browse the repository at this point in the history
Replace PR #105.

close #105

Signed-off-by: Stéphane Galland <galland@arakhne.org>
  • Loading branch information
gallandarakhneorg committed Jun 14, 2016
1 parent b4cddd4 commit 1fc8bfd
Show file tree
Hide file tree
Showing 159 changed files with 1,464 additions and 2,737 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.arakhne.afc.math.geometry.d2.Vector2D;
import org.arakhne.afc.math.geometry.d2.d.Vector2d;
import org.arakhne.afc.vmutil.ReflectionUtil;
import org.arakhne.afc.vmutil.annotations.ScalaOperator;
import org.arakhne.afc.vmutil.annotations.XtextOperator;
import org.arakhne.afc.vmutil.asserts.AssertMessages;
Expand Down Expand Up @@ -527,7 +528,7 @@ public void setLinear(Vector2D<?, ?> linear) {
@Pure
@Override
public String toString() {
return "linear:" + this.linear + "\nangular: " + this.angular; //$NON-NLS-1$ //$NON-NLS-2$
return ReflectionUtil.toString(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.arakhne.afc.math.geometry.d3.Point3D;
import org.arakhne.afc.ui.vector.Color;
import org.arakhne.afc.ui.vector.Image;
import org.arakhne.afc.vmutil.ReflectionUtil;

/**
* This class contains an attribute value.
Expand Down Expand Up @@ -433,23 +434,7 @@ public int hashCode() {
@Pure
@Override
public String toString() {
final StringBuilder str = new StringBuilder();
str.append('[');
str.append((this.name == null)
? "???" //$NON-NLS-1$
: this.name);
str.append('=');
try {
str.append((getValue() == null)
? "???" //$NON-NLS-1$
: getValue().toString());
} catch (AttributeException e) {
str.append("???"); //$NON-NLS-1$
}
str.append(':');
str.append(getType().toString());
str.append(']');
return str.toString();
return ReflectionUtil.toString(this);
}

/** Assert that the attribute value was assigned and not <code>null</code>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
import org.arakhne.afc.ui.vector.Color;
import org.arakhne.afc.ui.vector.Image;
import org.arakhne.afc.ui.vector.VectorToolkit;
import org.arakhne.afc.vmutil.ReflectionUtil;

/**
* This class contains an attribute value.
Expand All @@ -77,6 +78,8 @@ public class AttributeValueImpl implements AttributeValue {

private static final long serialVersionUID = 4014368008512085546L;

private static final String UUID_STR = "uuid"; //$NON-NLS-1$

/**
* Type of the metadata.
*/
Expand Down Expand Up @@ -599,15 +602,7 @@ public int hashCode() {
@Pure
@Override
public String toString() {
final StringBuilder str = new StringBuilder();
str.append("["); //$NON-NLS-1$
str.append((this.value == null)
? "???" //$NON-NLS-1$
: this.value.toString());
str.append(":"); //$NON-NLS-1$
str.append(this.type.toString());
str.append("]"); //$NON-NLS-1$
return str.toString();
return ReflectionUtil.toString(this);
}

@Pure
Expand Down Expand Up @@ -1747,7 +1742,7 @@ public void setColor(int red, int green, int blue, int alpha) {
private static UUID parseUUID(String text) {
try {
final URI uri = new URI(text);
if ("uuid".equalsIgnoreCase(uri.getScheme())) { //$NON-NLS-1$
if (UUID_STR.equalsIgnoreCase(uri.getScheme())) {
return UUID.fromString(uri.getHost());
}
} catch (Throwable exception) {
Expand Down Expand Up @@ -1784,7 +1779,7 @@ public UUID getUUID() throws InvalidAttributeTypeException, AttributeNotInitiali
return new UUID(id.getMostSignificantBits(), id.getLeastSignificantBits());
case URI:
final URI uri = (URI) this.value;
if ("uuid".equalsIgnoreCase(uri.getScheme())) { //$NON-NLS-1$
if (UUID_STR.equalsIgnoreCase(uri.getScheme())) {
return extractUUIDFromString(uri);
}
break;
Expand All @@ -1793,7 +1788,7 @@ public UUID getUUID() throws InvalidAttributeTypeException, AttributeNotInitiali
return (UUID) this.value;
}
if (this.value instanceof URI
&& "uuid".equalsIgnoreCase(((URI) this.value).getScheme())) { //$NON-NLS-1$
&& UUID_STR.equalsIgnoreCase(((URI) this.value).getScheme())) {
return extractUUIDFromString((URI) this.value);
}
break;
Expand Down Expand Up @@ -1924,7 +1919,7 @@ public URI getURI() throws InvalidAttributeTypeException, AttributeNotInitialize
case STRING:
return new URI((String) this.value);
case UUID:
return new URI("uuid:" + ((UUID) this.value).toString()); //$NON-NLS-1$
return new URI(UUID_STR + ":" + ((UUID) this.value).toString()); //$NON-NLS-1$
case OBJECT:
if (this.value instanceof URI) {
return (URI) this.value;
Expand All @@ -1933,7 +1928,7 @@ public URI getURI() throws InvalidAttributeTypeException, AttributeNotInitialize
return ((URL) this.value).toURI();
}
if (this.value instanceof UUID) {
return new URI("uuid:" + ((UUID) this.value).toString()); //$NON-NLS-1$
return new URI(UUID_STR + ":" + ((UUID) this.value).toString()); //$NON-NLS-1$
}
break;
case INET_ADDRESS:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ public void attributeImplFloat() throws Exception {
assertAttributeException(attr,"getPolyline");
assertAttributeException(attr,"getPolyline3D");
}

@Test
public void attributeImplDouble() throws Exception {
double nb = Math.random();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* limitations under the License.
*/

package org.arakhne.afc.math.geometry.d2;
package org.arakhne.afc.math.geometry;

/** Utility classes that provides the strings of characters for the typical JavaFX attribute names.
*
Expand Down Expand Up @@ -206,6 +206,10 @@ public final class MathFXAttributeNames {
*/
public static final String Z3 = "z3"; //$NON-NLS-1$

/** {@code CCW}.
*/
public static final String CCW = "ccw"; //$NON-NLS-1$

private MathFXAttributeNames() {
//
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import javafx.beans.property.SimpleObjectProperty;
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.geometry.d2.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.d2.afp.RectangularShape2afp;
import org.arakhne.afc.vmutil.asserts.AssertMessages;

Expand Down Expand Up @@ -306,22 +306,6 @@ public int hashCode() {
return b ^ (b >> 31);
}

@Pure
@Override
public String toString() {
final StringBuilder b = new StringBuilder();
b.append("("); //$NON-NLS-1$
b.append(getMinX());
b.append(", "); //$NON-NLS-1$
b.append(getMinY());
b.append(")-("); //$NON-NLS-1$
b.append(getMaxX());
b.append(", "); //$NON-NLS-1$
b.append(getMaxY());
b.append(")"); //$NON-NLS-1$
return b.toString();
}

@Override
public ObjectProperty<Rectangle2dfx> boundingBoxProperty() {
if (this.boundingBox == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.geometry.d2.Shape2D;
import org.arakhne.afc.vmutil.ReflectionUtil;

/** Abstract shape with 2 double precision floating-point FX properties.
*
Expand Down Expand Up @@ -69,4 +70,10 @@ public final GeomFactory2dfx getGeomFactory() {
return GeomFactory2dfx.SINGLETON;
}

@Pure
@Override
public String toString() {
return ReflectionUtil.toString(this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import javafx.beans.property.SimpleObjectProperty;
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.geometry.d2.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.d2.Point2D;
import org.arakhne.afc.math.geometry.d2.afp.Circle2afp;
import org.arakhne.afc.vmutil.asserts.AssertMessages;
Expand Down Expand Up @@ -114,19 +114,6 @@ public int hashCode() {
return bits ^ (bits >> 31);
}

@Pure
@Override
public String toString() {
final StringBuilder b = new StringBuilder();
b.append("center: ("); //$NON-NLS-1$
b.append(getX());
b.append(", "); //$NON-NLS-1$
b.append(getY());
b.append(")\nradius: "); //$NON-NLS-1$
b.append(getRadius());
return b.toString();
}

@Pure
@Override
public double getX() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import javafx.collections.ModifiableObservableListBase;
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.geometry.d2.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.d2.afp.MultiShape2afp;
import org.arakhne.afc.vmutil.asserts.AssertMessages;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import javafx.beans.property.SimpleObjectProperty;
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.geometry.d2.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.d2.Point2D;
import org.arakhne.afc.math.geometry.d2.Vector2D;
import org.arakhne.afc.math.geometry.d2.afp.OrientedPoint2afp;
Expand Down Expand Up @@ -199,27 +199,6 @@ public OrientedPoint2dfx clone() {
return clone;
}

@Override
public String toString() {
final StringBuilder b = new StringBuilder();
b.append("("); //$NON-NLS-1$
b.append(getX());
b.append(", "); //$NON-NLS-1$
b.append(getY());
b.append(")|("); //$NON-NLS-1$
b.append(getLength());
b.append(")|("); //$NON-NLS-1$
b.append(getDirectionX());
b.append(", "); //$NON-NLS-1$
b.append(getDirectionY());
b.append(")|("); //$NON-NLS-1$
b.append(getNormalX());
b.append(", "); //$NON-NLS-1$
b.append(getNormalY());
b.append(")"); //$NON-NLS-1$
return b.toString();
}

@Override
public double getX() {
return this.px == null ? 0 : this.px.doubleValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import javafx.beans.property.SimpleObjectProperty;
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.geometry.d2.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.d2.Point2D;
import org.arakhne.afc.math.geometry.d2.Vector2D;
import org.arakhne.afc.math.geometry.d2.afp.OrientedRectangle2afp;
Expand Down Expand Up @@ -184,30 +184,6 @@ public int hashCode() {
return bits ^ (bits >> 31);
}

@Pure
@Override
public String toString() {
final StringBuilder b = new StringBuilder();
b.append("["); //$NON-NLS-1$
b.append(getCenterX());
b.append(";"); //$NON-NLS-1$
b.append(getCenterY());
b.append(";"); //$NON-NLS-1$
b.append(getFirstAxisX());
b.append(";"); //$NON-NLS-1$
b.append(getFirstAxisY());
b.append(";"); //$NON-NLS-1$
b.append(getFirstAxisExtent());
b.append(";"); //$NON-NLS-1$
b.append(getSecondAxisX());
b.append(";"); //$NON-NLS-1$
b.append(getSecondAxisY());
b.append(";"); //$NON-NLS-1$
b.append(getSecondAxisExtent());
b.append("]"); //$NON-NLS-1$
return b.toString();
}

@Pure
@Override
public Point2dfx getCenter() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import javafx.beans.property.SimpleObjectProperty;
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.geometry.d2.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.d2.Point2D;
import org.arakhne.afc.math.geometry.d2.Vector2D;
import org.arakhne.afc.math.geometry.d2.afp.Parallelogram2afp;
Expand Down Expand Up @@ -193,30 +193,6 @@ public int hashCode() {
return bits ^ (bits >> 31);
}

@Pure
@Override
public String toString() {
final StringBuilder b = new StringBuilder();
b.append("["); //$NON-NLS-1$
b.append(getCenterX());
b.append(";"); //$NON-NLS-1$
b.append(getCenterY());
b.append(";"); //$NON-NLS-1$
b.append(getFirstAxisX());
b.append(";"); //$NON-NLS-1$
b.append(getFirstAxisY());
b.append(";"); //$NON-NLS-1$
b.append(getFirstAxisExtent());
b.append(";"); //$NON-NLS-1$
b.append(getSecondAxisX());
b.append(";"); //$NON-NLS-1$
b.append(getSecondAxisY());
b.append(";"); //$NON-NLS-1$
b.append(getSecondAxisExtent());
b.append("]"); //$NON-NLS-1$
return b.toString();
}

/** Replies the property for the x coordinate of the center.
*
* @return the property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
import org.eclipse.xtext.xbase.lib.Pure;

import org.arakhne.afc.math.MathConstants;
import org.arakhne.afc.math.geometry.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.PathElementType;
import org.arakhne.afc.math.geometry.PathWindingRule;
import org.arakhne.afc.math.geometry.d2.MathFXAttributeNames;
import org.arakhne.afc.math.geometry.d2.Point2D;
import org.arakhne.afc.math.geometry.d2.Transform2D;
import org.arakhne.afc.math.geometry.d2.afp.InnerComputationPoint2afp;
Expand Down Expand Up @@ -217,23 +217,6 @@ public int hashCode() {
return bits ^ (bits >> 31);
}

@Pure
@Override
public String toString() {
final StringBuilder b = new StringBuilder();
b.append("["); //$NON-NLS-1$
if (this.coords != null && !this.coords.isEmpty()) {
final Iterator<Double> iterator = this.coords.iterator();
b.append(iterator.next());
while (iterator.hasNext()) {
b.append(", "); //$NON-NLS-1$
b.append(iterator.next());
}
}
b.append("]"); //$NON-NLS-1$
return b.toString();
}

@Override
public void translate(double dx, double dy) {
if (this.coords != null && !this.coords.isEmpty()) {
Expand Down
Loading

0 comments on commit 1fc8bfd

Please sign in to comment.