X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=Workspace%2FSiman-Common%2Fsrc%2Forg%2Fsplat%2Fsom%2FRevision.java;h=6e79a5890f5b7426d8f2ababed7c6d88d3154e4f;hb=d322fbe7cd10ebd0a6e698b1c0e5402582e5d98c;hp=bc00b66b938d1ce942ebfbc0000d38c260285f6f;hpb=6e957e6de17ab1270e9b7669c46128cee66678c4;p=tools%2Fsiman.git diff --git a/Workspace/Siman-Common/src/org/splat/som/Revision.java b/Workspace/Siman-Common/src/org/splat/som/Revision.java index bc00b66..6e79a58 100644 --- a/Workspace/Siman-Common/src/org/splat/som/Revision.java +++ b/Workspace/Siman-Common/src/org/splat/som/Revision.java @@ -18,21 +18,20 @@ import org.splat.dal.bo.som.ProgressState; public class Revision { - private int major; - private int minor; - private int branch; + private transient int _major; + private transient int _minor; + private transient int _branch; public static class Format { -// -------------------------- - private String pattern; + private transient final String _pattern; - public Format (String pattern) { - this.pattern = pattern; + public Format (final String pattern) { + this._pattern = pattern; } - public String format (String verstring) { - CharBuffer version = CharBuffer.allocate(pattern.length() + 2*2); // Maximum possible size - char[] format = pattern.toCharArray(); + public String format (final String verstring) { + CharBuffer version = CharBuffer.allocate(_pattern.length() + 2*2); // Maximum possible size + char[] format = _pattern.toCharArray(); String[] vernum = verstring.split("\\x2E"); // version is suposed of the internal form (m.n.s) int branch = Integer.valueOf(vernum[2]); @@ -49,7 +48,11 @@ public class Revision { version.put(vernum[2]); } } else if (token == '[') { - if (branch == 0) while (format[i] != ']') i += 1; + if (branch == 0) { + while (format[i] != ']') { + i += 1; + } + } } else if (token == ']') { continue; } else { @@ -59,8 +62,8 @@ public class Revision { return new String(version.array(), 0, version.position()); } - public Revision parse (String verstring) throws ParseException { - char[] format = pattern.toCharArray(); + public Revision parse (final String verstring) throws ParseException { + char[] format = _pattern.toCharArray(); char[] version = verstring.toCharArray(); CharBuffer major = CharBuffer.allocate(4); CharBuffer minor = CharBuffer.allocate(4); @@ -74,19 +77,25 @@ public class Revision { token = format[i]; if (token == 'M') { while (cursor < version.length) { - if (!Character.isDigit(version[cursor])) break; + if (!Character.isDigit(version[cursor])) { + break; + } major.put(version[cursor]); cursor += 1; } } else if (token == 'm') { while (cursor < version.length) { - if (!Character.isDigit(version[cursor])) break; + if (!Character.isDigit(version[cursor])) { + break; + } minor.put(version[cursor]); cursor += 1; } } else if (token == 's') { while (cursor < version.length) { - if (!Character.isDigit(version[cursor])) break; + if (!Character.isDigit(version[cursor])) { + break; + } branch.put(version[cursor]); cursor += 1; } @@ -94,12 +103,18 @@ public class Revision { } else if (token == '[' || token == ']') { continue; } else { - if (version[cursor] != token) throw new ParseException(verstring, cursor); + if (version[cursor] != token) { + throw new ParseException(verstring, cursor); + } cursor += 1; } - if (cursor >= version.length) break; + if (cursor >= version.length) { + break; + } } - if (major.position() == 0) throw new ParseException(verstring, 0); + if (major.position() == 0) { + throw new ParseException(verstring, 0); + } String majnum = new String(major.array(), 0, major.position()); if (minor.position() == 0) { @@ -116,7 +131,7 @@ public class Revision { } public String toPattern () { - return pattern; + return _pattern; } } @@ -126,68 +141,73 @@ public class Revision { /** * Constructs a Revision object from the internal representation of a version number (m.n.s). */ - public Revision (String value) { + public Revision (final String value) { // ------------------------------ String[] vernum = value.split("\\x2E"); try { - this.major = Integer.valueOf(vernum[0]); - this.minor = Integer.valueOf(vernum[1]); - this.branch = Integer.valueOf(vernum[2]); + this._major = Integer.valueOf(vernum[0]); + this._minor = Integer.valueOf(vernum[1]); + this._branch = Integer.valueOf(vernum[2]); } catch (Exception e) { // NumberFormat or OutOfBound exception if value is not of the form m.n.s - this.major = 0; - this.minor = 0; - this.branch = 0; + this._major = 0; + this._minor = 0; + this._branch = 0; } } public Revision () { // ------------------ - this.major = 0; - this.minor = 0; - this.branch = 0; + this._major = 0; + this._minor = 0; + this._branch = 0; } - private Revision (int major, int minor) { + private Revision (final int major, final int minor) { // --------------------------------------- - this.major = major; - this.minor = minor; - this.branch = 0; + this._major = major; + this._minor = minor; + this._branch = 0; } - private Revision (int major, int minor, String branch) { + private Revision (final int major, final int minor, final String branch) { // ------------------------------------------------------ - this.major = major; - this.minor = minor; - this.branch = Integer.valueOf(branch); + this._major = major; + this._minor = minor; + this._branch = Integer.valueOf(branch); } // ============================================================================================================================== // Public member function // ============================================================================================================================== - public Revision incrementAs (ProgressState state) { + public Revision incrementAs (final ProgressState state) { // ------------------------------------------------- - if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) minor += 1; - else if (state == ProgressState.inCHECK) { - major = major + 1; - minor = 0; + if (state == ProgressState.inWORK || state == ProgressState.inDRAFT) { + _minor += 1; + } else if (state == ProgressState.inCHECK) { + _major = _major + 1; + _minor = 0; } return this; } - public boolean isGraterThan (Revision base) { + public boolean isGraterThan (final Revision base) { // ------------------------------------------ - if (this.major > base.major) return true; - if (this.major < base.major) return false; - return (this.minor > base.minor); + if (this._major > base._major) { + return true; + } + if (this._major < base._major) { + return false; + } + return (this._minor > base._minor); } public boolean isMinor () { // ------------------------- - return (minor != 0); + return (_minor != 0); } public boolean isNull () { // ------------------------ - return (major+minor == 0); + return (_major+_minor == 0); } /** * Sets the branch name of this revision. @@ -195,19 +215,20 @@ public class Revision { * @param name the branch name or the internal representation of a version number (m.n.s) * @return this revision object */ - public Revision setBranch (String name) { + public Revision setBranch (final String name) { // --------------------------------------- String[] vernum = name.split("\\x2E"); - branch = Integer.valueOf(vernum[vernum.length-1]); + _branch = Integer.valueOf(vernum[vernum.length-1]); return this; } /** * Returns the internal representation of a version number (m.n.s) represented by this Revision object. */ - public String toString () { + @Override + public String toString () { // ------------------------- StringBuffer version = new StringBuffer(); - return version.append(major).append(".").append(minor).append(".").append(branch).toString(); + return version.append(_major).append(".").append(_minor).append(".").append(_branch).toString(); } } \ No newline at end of file