Changeset 1249
- Timestamp:
- 09/05/08 08:11:40 (4 months ago)
- Files:
-
- trunk/dtool.descent.core/src-util/src-coreutil/META-INF (deleted)
- trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/Assert.java (modified) (6 diffs)
- trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/BitFields.java (deleted)
- trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/MiscUtil.java (moved) (moved from trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/Misc.java) (2 diffs, 1 prop)
- trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/StringUtil.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/Assert.java
r1232 r1249 43 43 } 44 44 45 public AssertionFailedException(String detail) { 46 super(detail); 45 public AssertionFailedException(String message) { 46 super(message); 47 } 48 49 @Override 50 public String toString() { 51 String message = getLocalizedMessage(); 52 return "AssertionFailedException" + ((message != null) ? (": " + message) : ""); 47 53 } 48 54 … … 59 65 if (!expression) { 60 66 expression = false; // dummy statement to allow breakpoint placement 61 throw new AssertionFailedException( "Assertion failed: " +message); //$NON-NLS-1$67 throw new AssertionFailedException(message); //$NON-NLS-1$ 62 68 } 63 69 return expression; … … 78 84 */ 79 85 public static boolean isTrue(boolean expression) { 80 return Assert.isTrue(expression, ""); //$NON-NLS-1$86 return Assert.isTrue(expression, null); //$NON-NLS-1$ 81 87 } 82 88 /** Like {@link #isTrue(boolean, String)} with empty message */ 83 89 public static boolean assertTrue(boolean expression) { 84 return Assert.isTrue(expression, ""); //$NON-NLS-1$90 return Assert.isTrue(expression, null); //$NON-NLS-1$ 85 91 } 86 92 … … 103 109 /** Like {@link #isNotNull(Object, String)} with empty message. */ 104 110 public static void isNotNull(Object object) { 105 Assert.isTrue(!(object == null), "");111 Assert.isTrue(!(object == null), null); 106 112 } 107 113 /** Like {@link #isNotNull(Object, String)} with empty message. */ 108 114 public static void assertNotNull(Object object) { 109 Assert.isTrue(!(object == null), "");115 Assert.isTrue(!(object == null), null); 110 116 } 111 117 … … 125 131 */ 126 132 public static AssertionFailedException fail(String msg) { 127 throw new AssertionFailedException( "Assert fail: " +msg);133 throw new AssertionFailedException(msg); 128 134 } 129 135 /** Causes an inconditional assertion failure, with message msg. … … 137 143 /** Like {@link #fail(String)} with empty message. */ 138 144 public static AssertionFailedException fail() { 139 throw new AssertionFailedException(" Assertfail.");145 throw new AssertionFailedException("fail."); 140 146 } 141 147 /** Like {@link #fail(String)} with empty message. */ trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/MiscUtil.java
- Property svn:mergeinfo set
r646 r1249 1 1 package melnorme.miscutil; 2 2 3 public class Misc { 3 import java.io.File; 4 import java.io.IOException; 5 import java.io.InputStream; 6 import java.util.ArrayList; 7 import java.util.Arrays; 8 9 public class MiscUtil { 4 10 5 11 /** Combines two hash codes to make a new one. */ … … 8 14 } 9 15 16 /** Runs a shell command as a Process and waits for it to terminate. 17 * Assumes the process does not read input. 18 * @return exit value of the process */ 19 public static int runShellCommand(String directory, String cmd, String... args) throws IOException { 20 ProcessBuilder procBuilder = new ProcessBuilder(); 21 ArrayList<String> cmdList = new ArrayList<String>(args.length+1); 22 cmdList.add(cmd); 23 cmdList.addAll(Arrays.asList(args)); 24 procBuilder.command(cmdList); 25 procBuilder.redirectErrorStream(true); 26 procBuilder.directory(new File(directory)); 27 28 Process process = procBuilder.start(); 29 InputStream inputStream = process.getInputStream(); 30 int ch; 31 while ((ch = inputStream.read()) != -1) { 32 //read proccess's stdout and stderr 33 if(false) 34 System.out.print((char)ch); 35 } 36 37 try { 38 return process.waitFor(); 39 } catch (InterruptedException e) { 40 throw melnorme.miscutil.ExceptionAdapter.unchecked(e); 41 } 42 } 43 44 /** 45 * Counts the active flags in the given bitfield 46 */ 47 public static int countActiveFlags(int bitfield, int[] flags) { 48 int count = 0; 49 for (int i = 0; i < flags.length; i++) { 50 if((bitfield & flags[i]) != 0) 51 count++; 52 } 53 return count; 54 } 55 10 56 } trunk/dtool.descent.core/src-util/src-coreutil/melnorme/miscutil/StringUtil.java
r1232 r1249 108 108 } 109 109 110 /** Return "" if string is null, or the unmodified string otherwise. */ 111 public static String nullAsEmpty(String string) { 112 if(string == null) 113 return ""; 114 return string; 115 } 116 110 117 111 118 }
