├── .gitignore ├── lib ├── mail.jar ├── OpenCSV.jar ├── ojdbc6.jar ├── commons-lang3-3.1.jar └── JFolderChooser-0.9.jar ├── dist ├── lib │ ├── mail.jar │ ├── OpenCSV.jar │ ├── ojdbc6.jar │ ├── commons-lang3-3.1.jar │ └── JFolderChooser-0.9.jar ├── JavaHelper.jar ├── javadoc │ ├── resources │ │ ├── tab.gif │ │ ├── titlebar.gif │ │ ├── background.gif │ │ └── titlebar_end.gif │ ├── package-list │ ├── com │ │ └── kentcdodds │ │ │ └── javahelper │ │ │ ├── test │ │ │ ├── package-frame.html │ │ │ ├── package-use.html │ │ │ ├── class-use │ │ │ │ ├── TestClass.html │ │ │ │ └── TestArchive.html │ │ │ ├── package-tree.html │ │ │ └── package-summary.html │ │ │ ├── extras │ │ │ ├── package-frame.html │ │ │ ├── package-use.html │ │ │ ├── class-use │ │ │ │ ├── MessageConsole.html │ │ │ │ └── LimitLinesDocumentListener.html │ │ │ ├── package-tree.html │ │ │ └── package-summary.html │ │ │ ├── model │ │ │ └── package-frame.html │ │ │ └── helpers │ │ │ ├── package-frame.html │ │ │ ├── class-use │ │ │ ├── IOHelper.html │ │ │ ├── SQLHelper.html │ │ │ ├── XMLHelper.html │ │ │ ├── DateHelper.html │ │ │ ├── DebugHelper.html │ │ │ ├── EmailHelper.html │ │ │ ├── OtherHelper.html │ │ │ ├── SwingHelper.html │ │ │ ├── NumberHelper.html │ │ │ ├── RandomHelper.html │ │ │ ├── StringHelper.html │ │ │ ├── ReflectionHelper.html │ │ │ └── StringFormatHelper.html │ │ │ └── package-use.html │ ├── overview-frame.html │ ├── index.html │ ├── allclasses-noframe.html │ ├── deprecated-list.html │ ├── allclasses-frame.html │ ├── serialized-form.html │ ├── overview-summary.html │ └── index-files │ │ └── index-22.html └── README.TXT ├── store └── JavaHelper.jar ├── src └── com │ └── kentcdodds │ └── javahelper │ ├── resources │ ├── Thumbs.db │ ├── iSayHiGuy.jpg │ └── progressWheel.gif │ ├── helpers │ ├── DebugHelper.java │ ├── XMLHelper.java │ ├── OtherHelper.java │ ├── NumberHelper.java │ ├── StringFormatHelper.java │ ├── DateHelper.java │ ├── SQLHelper.java │ └── PrinterHelper.java │ ├── model │ ├── HelperQuery.java │ ├── QueryParameter.java │ └── HelperFile.java │ ├── test │ └── TestClass.java │ └── extras │ └── LimitLinesDocumentListener.java ├── nbproject ├── genfiles.properties ├── project.xml └── project.properties └── README /.gitignore: -------------------------------------------------------------------------------- 1 | /build/ 2 | /nbproject/private/ -------------------------------------------------------------------------------- /lib/mail.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/lib/mail.jar -------------------------------------------------------------------------------- /lib/OpenCSV.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/lib/OpenCSV.jar -------------------------------------------------------------------------------- /lib/ojdbc6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/lib/ojdbc6.jar -------------------------------------------------------------------------------- /dist/lib/mail.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/lib/mail.jar -------------------------------------------------------------------------------- /dist/JavaHelper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/JavaHelper.jar -------------------------------------------------------------------------------- /dist/lib/OpenCSV.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/lib/OpenCSV.jar -------------------------------------------------------------------------------- /dist/lib/ojdbc6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/lib/ojdbc6.jar -------------------------------------------------------------------------------- /store/JavaHelper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/store/JavaHelper.jar -------------------------------------------------------------------------------- /lib/commons-lang3-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/lib/commons-lang3-3.1.jar -------------------------------------------------------------------------------- /lib/JFolderChooser-0.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/lib/JFolderChooser-0.9.jar -------------------------------------------------------------------------------- /dist/javadoc/resources/tab.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/javadoc/resources/tab.gif -------------------------------------------------------------------------------- /dist/lib/commons-lang3-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/lib/commons-lang3-3.1.jar -------------------------------------------------------------------------------- /dist/lib/JFolderChooser-0.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/lib/JFolderChooser-0.9.jar -------------------------------------------------------------------------------- /dist/javadoc/resources/titlebar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/javadoc/resources/titlebar.gif -------------------------------------------------------------------------------- /dist/javadoc/resources/background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/javadoc/resources/background.gif -------------------------------------------------------------------------------- /dist/javadoc/resources/titlebar_end.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/dist/javadoc/resources/titlebar_end.gif -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/resources/Thumbs.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/src/com/kentcdodds/javahelper/resources/Thumbs.db -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/resources/iSayHiGuy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/src/com/kentcdodds/javahelper/resources/iSayHiGuy.jpg -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/resources/progressWheel.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kentcdodds/Java-Helper/HEAD/src/com/kentcdodds/javahelper/resources/progressWheel.gif -------------------------------------------------------------------------------- /dist/javadoc/package-list: -------------------------------------------------------------------------------- 1 | com.kentcdodds.javahelper.extras 2 | com.kentcdodds.javahelper.helpers 3 | com.kentcdodds.javahelper.model 4 | com.kentcdodds.javahelper.test 5 | -------------------------------------------------------------------------------- /nbproject/genfiles.properties: -------------------------------------------------------------------------------- 1 | build.xml.data.CRC32=d437d9ac 2 | build.xml.script.CRC32=7265a3b1 3 | build.xml.stylesheet.CRC32=28e38971@1.50.2.46 4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. 5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. 6 | nbproject/build-impl.xml.data.CRC32=f5af79c8 7 | nbproject/build-impl.xml.script.CRC32=6bf076ff 8 | nbproject/build-impl.xml.stylesheet.CRC32=fcddb364@1.50.3.46 9 | -------------------------------------------------------------------------------- /nbproject/project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | org.netbeans.modules.java.j2seproject 4 | 5 | 6 | JavaHelper 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/test/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.test 8 | 9 | 10 | 11 | 12 |

com.kentcdodds.javahelper.test

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/extras/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.extras 8 | 9 | 10 | 11 | 12 |

com.kentcdodds.javahelper.extras

13 |
14 |

Classes

15 | 19 |
20 | 21 | 22 | -------------------------------------------------------------------------------- /dist/javadoc/overview-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview List 8 | 9 | 10 | 11 | 12 |
All Classes
13 |
14 |

Packages

15 | 21 |
22 |

 

23 | 24 | 25 | -------------------------------------------------------------------------------- /dist/README.TXT: -------------------------------------------------------------------------------- 1 | ======================== 2 | BUILD OUTPUT DESCRIPTION 3 | ======================== 4 | 5 | When you build an Java application project that has a main class, the IDE 6 | automatically copies all of the JAR 7 | files on the projects classpath to your projects dist/lib folder. The IDE 8 | also adds each of the JAR files to the Class-Path element in the application 9 | JAR files manifest file (MANIFEST.MF). 10 | 11 | To run the project from the command line, go to the dist folder and 12 | type the following: 13 | 14 | java -jar "JavaHelper.jar" 15 | 16 | To distribute this project, zip up the dist folder (including the lib folder) 17 | and distribute the ZIP file. 18 | 19 | Notes: 20 | 21 | * If two JAR files on the project classpath have the same name, only the first 22 | JAR file is copied to the lib folder. 23 | * Only JAR files are copied to the lib folder. 24 | If the classpath contains other types of files or folders, these files (folders) 25 | are not copied. 26 | * If a library on the projects classpath also has a Class-Path element 27 | specified in the manifest,the content of the Class-Path element has to be on 28 | the projects runtime path. 29 | * To set a main class in a standard Java project, right-click the project node 30 | in the Projects window and choose Properties. Then click Run and enter the 31 | class name in the Main Class field. Alternatively, you can manually type the 32 | class name in the manifest Main-Class element. 33 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/model/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.model 8 | 9 | 10 | 11 | 12 |

com.kentcdodds.javahelper.model

13 |
14 |

Classes

15 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /dist/javadoc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Generated Documentation (Untitled) 8 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | <noscript> 28 | <div>JavaScript is disabled on your browser.</div> 29 | </noscript> 30 | <h2>Frame Alert</h2> 31 | <p>This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. Link to <a href="overview-summary.html">Non-frame version</a>.</p> 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/DebugHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | /** 4 | * 5 | * @author kentcdodds 6 | */ 7 | public class DebugHelper { 8 | 9 | /** 10 | * Calls getLineNumber(3). It's doing three because the method which calls this method will be 3 away from the 11 | * beginning of the stack trace 12 | * 13 | * @return 14 | * @see getLineNumber(int numberBack) 15 | */ 16 | public static int getLineNumber() { 17 | return getLineNumber(3); 18 | } 19 | 20 | /** 21 | * Returns the line number on the stack trace the given number back on the trace. Normally, if you want the line 22 | * number of the caller of this method you'll give 2 (or call the convenience method which defaults to 2). This kind 23 | * of method is useful for debugging purposes mostly 24 | * 25 | * @param numberBack the number on the stack trace to get the line number from. 26 | * @return the line number on the stack trace numberBack away from given trace (the method which calls this would be 27 | * "2" numberBack 28 | */ 29 | public static int getLineNumber(int numberBack) { 30 | return Thread.currentThread().getStackTrace()[numberBack].getLineNumber(); 31 | } 32 | 33 | /** 34 | * Helpful for debugging. Give 2 for the line which is calling this method. 35 | * 36 | * @param numberBack 37 | * @return className + "." + methodName + "():" + lineNumber of the specified number back on the stack trace. 38 | * @see getDebugInfo() 39 | */ 40 | public static String getDebugInfo(int numberBack) { 41 | String className = Thread.currentThread().getStackTrace()[numberBack].getClassName(); 42 | String methodName = Thread.currentThread().getStackTrace()[numberBack].getMethodName(); 43 | int lineNumber = getLineNumber(numberBack + 1); 44 | 45 | return className + "." + methodName + "(): " + lineNumber; 46 | } 47 | 48 | public static String getDebugInfo() { 49 | return getDebugInfo(3); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/model/HelperQuery.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.model; 2 | 3 | import java.sql.ResultSet; 4 | 5 | /** 6 | * Javabean for the SQLHelper. Used in HelperConnection 7 | * 8 | * @author kentcdodds 9 | */ 10 | public class HelperQuery { 11 | 12 | private String query; 13 | private java.util.List parametersList; 14 | private ResultSet resultSet; 15 | 16 | /** 17 | * Empty Constructor. Be sure to set the query and parameters. 18 | */ 19 | public HelperQuery() { 20 | parametersList = new java.util.ArrayList<>(); 21 | } 22 | 23 | /** 24 | * Partial constructor. Fills the query parameters with one array of parameters. 25 | * 26 | * @param connection 27 | * @param query 28 | * @param parameters 29 | */ 30 | public HelperQuery(String query, QueryParameter... parameters) { 31 | this.query = query; 32 | parametersList = new java.util.ArrayList<>(); 33 | parametersList.add(parameters); 34 | } 35 | 36 | /** 37 | * Full constructor except for the result set. This is set by the HelperConnection which runs it when it is executed. 38 | * 39 | * @param connection 40 | * @param query 41 | * @param parameters 42 | */ 43 | public HelperQuery(String query, java.util.List parametersList) { 44 | this.query = query; 45 | this.parametersList = parametersList; 46 | } 47 | 48 | /** 49 | * @return the query 50 | */ 51 | public String getQuery() { 52 | return query; 53 | } 54 | 55 | /** 56 | * @param query the query to set 57 | */ 58 | public void setQuery(String query) { 59 | this.query = query; 60 | } 61 | 62 | /** 63 | * @return the parameters 64 | */ 65 | public java.util.List getParametersList() { 66 | return parametersList; 67 | } 68 | 69 | /** 70 | * @param parameters the parameters to set 71 | */ 72 | public void setParametersList(java.util.List parameters) { 73 | this.parametersList = parameters; 74 | } 75 | 76 | /** 77 | * @return the rs 78 | */ 79 | public ResultSet getResultSet() { 80 | return resultSet; 81 | } 82 | 83 | /** 84 | * @param resultSet the ResultSet to set 85 | */ 86 | public void setResultSet(ResultSet resultSet) { 87 | this.resultSet = resultSet; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/XMLHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | import java.io.IOException; 4 | import java.io.StringReader; 5 | import java.io.StringWriter; 6 | import java.util.logging.Level; 7 | import java.util.logging.Logger; 8 | import javax.xml.parsers.DocumentBuilder; 9 | import javax.xml.parsers.DocumentBuilderFactory; 10 | import javax.xml.parsers.ParserConfigurationException; 11 | import javax.xml.transform.Transformer; 12 | import javax.xml.transform.TransformerException; 13 | import javax.xml.transform.TransformerFactory; 14 | import javax.xml.transform.dom.DOMSource; 15 | import javax.xml.transform.stream.StreamResult; 16 | import org.w3c.dom.Document; 17 | import org.xml.sax.InputSource; 18 | import org.xml.sax.SAXException; 19 | import org.xml.sax.SAXParseException; 20 | 21 | /** 22 | * 23 | * @author Kent 24 | */ 25 | public class XMLHelper { 26 | 27 | /** 28 | * Uses the DocumentBuilderFactory to create a new doc and returns it 29 | * 30 | * @return Document object called doc 31 | */ 32 | public static Document createDoc() throws ParserConfigurationException { 33 | DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 34 | DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); 35 | return dBuilder.newDocument(); 36 | } 37 | 38 | /** 39 | * This method will transform an XML doc to a String. Returns null if there's an error. 40 | * 41 | * @param doc 42 | * @return xmlString 43 | */ 44 | public static String transformDoc(Document doc) throws TransformerException { 45 | DOMSource domSource = new DOMSource(doc); 46 | StringWriter writer = new StringWriter(); 47 | StreamResult result = new StreamResult(writer); 48 | TransformerFactory tf = TransformerFactory.newInstance(); 49 | Transformer transformer = tf.newTransformer(); 50 | transformer.transform(domSource, result); 51 | return writer.toString(); 52 | } 53 | 54 | /** 55 | * This method will Read the XML and act accordingly 56 | * 57 | * @param xmlString - the XML String 58 | * @return the list of elements within the XML 59 | */ 60 | public static Document readXML(String xmlString) throws SAXParseException, SAXException, ParserConfigurationException, IOException { 61 | DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); 62 | DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); 63 | InputSource xmlStream = new InputSource(); 64 | xmlStream.setCharacterStream(new StringReader(xmlString)); 65 | return dBuilder.parse(xmlStream); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/package-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.helpers 8 | 9 | 10 | 11 | 12 |

com.kentcdodds.javahelper.helpers

13 |
14 |

Classes

15 | 31 |
32 | 33 | 34 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/test/TestClass.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.test; 2 | 3 | import com.kentcdodds.javahelper.helpers.*; 4 | import java.io.File; 5 | import java.io.FileInputStream; 6 | import java.io.IOException; 7 | import java.util.List; 8 | import java.util.Map; 9 | import java.util.Properties; 10 | import java.util.TreeMap; 11 | 12 | /** 13 | * 14 | * @author Kent 15 | */ 16 | public class TestClass { 17 | 18 | public static String testImageLocation = "/com/kentcdodds/javahelper/resources/iSayHiGuy.jpg"; 19 | public static String progressImageUrl = "http://c96265.r65.cf3.rackcdn.com/indicator_medium.gif"; 20 | public static File ioPlaygroundDir = new File(IOHelper.homeDir + "\\IOPlayground\\"); 21 | public static String prodDatabaseUrl; 22 | public static String devDatabaseUrl; 23 | public static String dbPassword; 24 | public static String dbUser; 25 | public static String gmailUser; 26 | public static String gmailPassword; 27 | public static String ldsUser; 28 | public static String ldsPassword; 29 | public static Properties mailServerProperties; 30 | public static Properties sqlProperties; 31 | 32 | public static void main(String[] args) throws Exception { 33 | setStuff(); 34 | System.exit(0); 35 | } 36 | 37 | /** 38 | * The stuff I want to set at the beginning of all my tests. Loads a sqlProperties file which holds the values to 39 | * personal variables (passwords, etc.) 40 | */ 41 | public static void setStuff() throws IOException { 42 | SwingHelper.setSystemLookAndFeel(); 43 | PrinterHelper.setInstancePrint(true); 44 | Properties prop = new Properties(); 45 | 46 | prop.load(new FileInputStream("../java-helper.properties")); 47 | 48 | devDatabaseUrl = prop.getProperty("devDatabase"); 49 | prodDatabaseUrl = prop.getProperty("prodDatabase"); 50 | dbPassword = OtherHelper.descrambleString(prop.getProperty("dbScrambledPassword")); 51 | dbUser = prop.getProperty("dbUser"); 52 | sqlProperties = new Properties(); 53 | sqlProperties.put("user", dbUser); 54 | sqlProperties.put("password", dbPassword); 55 | 56 | mailServerProperties = new Properties(); 57 | mailServerProperties.setProperty("mail.smtp.host", prop.getProperty("mail.smtp.host")); 58 | mailServerProperties.setProperty("mail.smtp.port", prop.getProperty("mail.smtp.port")); 59 | 60 | gmailUser = prop.getProperty("gmailUser"); 61 | gmailPassword = OtherHelper.descrambleString(prop.getProperty("gmailScrambledPassword")); 62 | 63 | ldsUser = prop.getProperty("ldsUser"); 64 | ldsPassword = OtherHelper.descrambleString(prop.getProperty("ldsScrambledPassword")); 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /nbproject/project.properties: -------------------------------------------------------------------------------- 1 | annotation.processing.enabled=true 2 | annotation.processing.enabled.in.editor=false 3 | annotation.processing.processors.list= 4 | annotation.processing.run.all.processors=true 5 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output 6 | application.title=JavaHelper 7 | application.vendor=Kent 8 | build.classes.dir=${build.dir}/classes 9 | build.classes.excludes=**/*.java,**/*.form 10 | # This directory is removed when the project is cleaned: 11 | build.dir=build 12 | build.generated.dir=${build.dir}/generated 13 | build.generated.sources.dir=${build.dir}/generated-sources 14 | # Only compile against the classpath explicitly listed here: 15 | build.sysclasspath=ignore 16 | build.test.classes.dir=${build.dir}/test/classes 17 | build.test.results.dir=${build.dir}/test/results 18 | # Uncomment to specify the preferred debugger connection transport: 19 | #debug.transport=dt_socket 20 | debug.classpath=\ 21 | ${run.classpath} 22 | debug.test.classpath=\ 23 | ${run.test.classpath} 24 | # This directory is removed when the project is cleaned: 25 | dist.dir=dist 26 | dist.jar=${dist.dir}/JavaHelper.jar 27 | dist.javadoc.dir=${dist.dir}/javadoc 28 | endorsed.classpath= 29 | excludes= 30 | file.reference.commons-lang3-3.1.jar=lib\\commons-lang3-3.1.jar 31 | file.reference.JFolderChooser-0.9.jar=lib\\JFolderChooser-0.9.jar 32 | file.reference.mail.jar=lib\\mail.jar 33 | file.reference.ojdbc6.jar=lib\\ojdbc6.jar 34 | file.reference.OpenCSV.jar=lib\\OpenCSV.jar 35 | includes=** 36 | jar.compress=false 37 | javac.classpath=\ 38 | ${file.reference.mail.jar}:\ 39 | ${file.reference.JFolderChooser-0.9.jar}:\ 40 | ${file.reference.commons-lang3-3.1.jar}:\ 41 | ${file.reference.ojdbc6.jar}:\ 42 | ${file.reference.OpenCSV.jar} 43 | # Space-separated list of extra javac options 44 | javac.compilerargs= 45 | javac.deprecation=false 46 | javac.processorpath=\ 47 | ${javac.classpath} 48 | javac.source=1.7 49 | javac.target=1.7 50 | javac.test.classpath=\ 51 | ${javac.classpath}:\ 52 | ${build.classes.dir} 53 | javac.test.processorpath=\ 54 | ${javac.test.classpath} 55 | javadoc.additionalparam= 56 | javadoc.author=false 57 | javadoc.encoding=${source.encoding} 58 | javadoc.noindex=false 59 | javadoc.nonavbar=false 60 | javadoc.notree=false 61 | javadoc.private=false 62 | javadoc.splitindex=true 63 | javadoc.use=true 64 | javadoc.version=false 65 | javadoc.windowtitle= 66 | meta.inf.dir=${src.dir}/META-INF 67 | mkdist.disabled=false 68 | platform.active=JDK_1.7 69 | run.classpath=\ 70 | ${javac.classpath}:\ 71 | ${build.classes.dir} 72 | # Space-separated list of JVM arguments used when running the project 73 | # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value 74 | # or test-sys-prop.name=value to set system properties for unit tests): 75 | run.jvmargs= 76 | run.test.classpath=\ 77 | ${javac.test.classpath}:\ 78 | ${build.test.classes.dir} 79 | source.encoding=UTF-8 80 | src.dir=src 81 | test.src.dir=test 82 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/OtherHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | import java.io.Console; 4 | import java.util.Scanner; 5 | 6 | /** 7 | * Holds helper methods that haven't found a home yet 8 | * 9 | * @author Kent 10 | */ 11 | public class OtherHelper { 12 | 13 | /** 14 | * Checks whether any of the given parameters are null 15 | * 16 | * @param object the object/objects/array of objects to check 17 | * @return true if any give parameter is null 18 | */ 19 | public static boolean isNull(Object... object) { 20 | for (Object object1 : object) { 21 | if (object1 == null) { 22 | return true; 23 | } 24 | } 25 | return false; 26 | } 27 | 28 | /** 29 | * This removes the items given in the first list from the second list 30 | * 31 | * @param thisList 32 | * @param thatList 33 | */ 34 | public static void removeThisFromThat(java.util.List thisList, java.util.List thatList) { 35 | for (Object removeObject : thisList) { 36 | thatList.remove(removeObject); 37 | } 38 | } 39 | 40 | /** 41 | * Read a password from the consol (hides the user's input) 42 | * 43 | * @param message 44 | * @return 45 | */ 46 | public static String readPassword(String message, Scanner input) { 47 | String password; 48 | Console console = System.console(); 49 | if (console != null) { 50 | char[] secretValue = System.console().readPassword(message); 51 | password = new String(secretValue); 52 | } else { 53 | System.out.print(message); 54 | password = input.nextLine(); 55 | } 56 | return password; 57 | } 58 | 59 | /** 60 | * Scrambles the password into a comma separated string of bytes (and then prints out a descramble to check it 61 | * worked). REALLY simple algorithm. Pretty much only good for being able to have someone look at your code without 62 | * being able to remember your password, but I wouldn't recommend posting what the scrambler results are online. It'd 63 | * be really easy to figure out. 64 | */ 65 | public static void scrambleString(String string) { 66 | StringBuilder byteString = new StringBuilder(); 67 | for (byte b : string.getBytes()) { 68 | b = (byte) (b + 3); 69 | byteString.append(b).append(","); 70 | } 71 | System.out.println(byteString); 72 | System.out.println(descrambleString(byteString.toString())); 73 | } 74 | 75 | /** 76 | * Descrambles a password which was scrambled with the scrambler. REALLY simple algorithm. Pretty much only good for 77 | * being able to have someone look at your code without being able to remember your password, but I wouldn't recommend 78 | * posting what the scrambler results are online. It'd be really easy to figure out. 79 | * 80 | * @param scramble 81 | * @return 82 | */ 83 | public static String descrambleString(String scramble) { 84 | String[] split = scramble.split(","); 85 | byte[] bytes = new byte[split.length]; 86 | for (int i = 0; i < split.length; i++) { 87 | bytes[i] = (byte) (Byte.valueOf(split[i]).byteValue() - 3); 88 | } 89 | return new String(bytes); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/model/QueryParameter.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.model; 2 | 3 | /** 4 | * Javabean for the SQLHelper. Used in HelperQuery. 5 | * 6 | * @author kentcdodds 7 | */ 8 | public class QueryParameter { 9 | 10 | public static final int ARRAY = 100, ASCIISTREAM = 101, BIGDECIMAL = 102, BINARYSTREAM = 103, 11 | BLOB = 104, BOOLEAN = 105, BYTE = 106, BYTES = 107, CHARACTERSTREAM = 108, CLOB = 109, 12 | DATE = 110, DOUBLE = 111, FLOAT = 112, INT = 113, LONG = 114, NCHARACTERSTREAM = 115, 13 | NCLOB = 116, NSTRING = 117, OBJECT = 118, REF = 119, ROWID = 120, SHORT = 121, 14 | SQLXML = 122, STRING = 123, TIME = 124, TIMESTAMP = 125, URL = 126, UNSET = -1; 15 | private int type = UNSET; //not initialized 16 | private Object value = null; 17 | 18 | /** 19 | * Constructor for QueryParameter 20 | */ 21 | public QueryParameter(int type, String value) { 22 | this.type = type; 23 | this.value = value; 24 | } 25 | 26 | /** 27 | * @return the type 28 | */ 29 | public int getType() { 30 | return type; 31 | } 32 | 33 | /** 34 | * @param type the type to set 35 | */ 36 | public void setType(int type) { 37 | this.type = type; 38 | } 39 | 40 | /** 41 | * @return the value 42 | */ 43 | public Object getValue() { 44 | return value; 45 | } 46 | 47 | /** 48 | * @param value the value to set 49 | */ 50 | public void setValue(Object value) { 51 | this.value = value; 52 | } 53 | 54 | /** 55 | * Returns a string version of the type of this query parameter 56 | * 57 | * @return 58 | */ 59 | public String getTypeString() { 60 | switch (type) { 61 | case ARRAY: 62 | return "Array"; 63 | case ASCIISTREAM: 64 | return "Ascii Stream"; 65 | case BIGDECIMAL: 66 | return "Big Decimal"; 67 | case BINARYSTREAM: 68 | return "Binary Stream"; 69 | case BLOB: 70 | return "Blob"; 71 | case BOOLEAN: 72 | return "Boolean"; 73 | case BYTE: 74 | return "Byte"; 75 | case BYTES: 76 | return "Bytes"; 77 | case CHARACTERSTREAM: 78 | return "Character Stream"; 79 | case CLOB: 80 | return "Clob"; 81 | case DATE: 82 | return "Date"; 83 | case DOUBLE: 84 | return "Double"; 85 | case FLOAT: 86 | return "Float"; 87 | case INT: 88 | return "Int"; 89 | case LONG: 90 | return "Long"; 91 | case NCHARACTERSTREAM: 92 | return "N Character Stream"; 93 | case NCLOB: 94 | return "N Clob"; 95 | case NSTRING: 96 | return "N String"; 97 | case OBJECT: 98 | return "Object"; 99 | case REF: 100 | return "Ref"; 101 | case ROWID: 102 | return "RowId"; 103 | case SHORT: 104 | return "Short"; 105 | case SQLXML: 106 | return "SQL XML"; 107 | case STRING: 108 | return "String"; 109 | case TIME: 110 | return "Time"; 111 | case TIMESTAMP: 112 | return "Timestamp"; 113 | case URL: 114 | return "URL"; 115 | case UNSET: 116 | return "Not defined (-1)"; 117 | } 118 | return "Unknown (" + type + ")"; 119 | } 120 | 121 | @Override 122 | public String toString() { 123 | return getTypeString() + " ==> " + value; 124 | } 125 | } -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/NumberHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | import java.math.BigDecimal; 4 | 5 | /** 6 | * 7 | * @author Kent 8 | */ 9 | public class NumberHelper { 10 | 11 | /** 12 | * Convenience method. Calls isValidNumber on parameters with the given class. 13 | * 14 | * @param c the number type. Valid types are (wrappers included): double, int, float, long. 15 | * @param numStrings the string/strings/array of strings to check 16 | * @return false if any return false on the isValidNumber call 17 | */ 18 | public static boolean areValidNumbers(Class c, String... numStrings) { 19 | for (String numString : numStrings) { 20 | if (!isValidNumber(c, numString)) { 21 | return false; 22 | } 23 | } 24 | return true; 25 | } 26 | 27 | /** 28 | * Does a try catch (Exception) on parsing the given string to the given type 29 | * 30 | * @param c the number type. Valid types are (wrappers included): double, int, float, long. 31 | * @param numString number to check 32 | * @return false if there is an exception, true otherwise 33 | */ 34 | public static boolean isValidNumber(Class c, String numString) { 35 | try { 36 | if (c == double.class || c == Double.class) { 37 | Double.parseDouble(numString); 38 | } else if (c == int.class || c == Integer.class) { 39 | Integer.parseInt(numString); 40 | } else if (c == float.class || c == Float.class) { 41 | Float.parseFloat(numString); 42 | } else if (c == long.class || c == Long.class) { 43 | Long.parseLong(numString); 44 | } 45 | } catch (Exception ex) { 46 | return false; 47 | } 48 | return true; 49 | } 50 | 51 | /** 52 | * Rounds the given amount half up by two digits (good for money) 53 | * 54 | * @param amount the double to round 55 | * @return the rounded amount 56 | */ 57 | public static double round(double amount) { 58 | return round(amount, 2); 59 | } 60 | 61 | /** 62 | * Rounds the given amount half up to the given digits 63 | * 64 | * @param amount the double to round 65 | * @param digits the digits to round to 66 | * @return the rounded amount 67 | */ 68 | public static double round(double amount, int digits) { 69 | return round(amount, digits, BigDecimal.ROUND_HALF_UP); 70 | } 71 | 72 | /** 73 | * Rounds the given amount by the given digits in the given direction 74 | * 75 | * @param amount the double to round 76 | * @param digits the digits to round to 77 | * @param round the type of round to perform 78 | * @return the rounded amount for example BigDecimal.ROUND_HALF_UP 79 | */ 80 | public static double round(double amount, int digits, int round) { 81 | return Double.parseDouble(new BigDecimal(amount).setScale(digits, round).toString()); 82 | } 83 | 84 | /** 85 | * Gets the percent of the subtotal verses the total 86 | * 87 | * @param subtotal 88 | * @param total 89 | * @return 90 | */ 91 | public static int getPercentFromTotal(int subtotal, int total) { 92 | return (int) (((float) subtotal / (float) total) * 100); 93 | } 94 | 95 | /** 96 | * Removes all non number characters. Note: does not remove decimals (.) so a given number like this: 93)23.42-235.234 97 | * will come out looking like this 9323.42235.234 98 | * 99 | * @param number 100 | * @return 101 | */ 102 | public static String cleanNumber(String number) { 103 | char[] toCharArray = number.toCharArray(); 104 | StringBuilder sb = new StringBuilder(); 105 | for (char c : toCharArray) { 106 | if (Character.isDigit(c) || c == '.') { 107 | sb.append(c); 108 | } 109 | } 110 | return sb.toString(); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/model/HelperFile.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.model; 2 | 3 | import com.kentcdodds.javahelper.helpers.IOHelper; 4 | import java.io.*; 5 | 6 | /** 7 | * This class is really helpful for dealing with files in memory. The major difference between this and a regular file 8 | * (which it extends) is this has a byte[] of its bytes which can be set and therefore you can hand this around as a 9 | * regular file but treat it like it exists only in memory. The IOHelper and the EmailHelper each have methods which 10 | * can use this class powerfully. 11 | * 12 | * @author kentcdodds 13 | */ 14 | public class HelperFile extends File { 15 | 16 | private byte[] bytes; 17 | 18 | /** 19 | * Constructor for HelperFile. Calls generateBytes() when path has been set 20 | * 21 | * @param path the path to the file 22 | * @throws FileNotFoundException when trying to read the file 23 | * @throws IOException when trying to read the bytes into the byte[] 24 | * @throws Exception when trying to read the bytes into the array 25 | */ 26 | public HelperFile(String path) throws FileNotFoundException, IOException, Exception { 27 | super(path); 28 | generateBytes(); 29 | } 30 | 31 | /** 32 | * Constructor for HelperFile. Calls generateBytes() when path has been set 33 | * 34 | * @param file getPath is called in super() 35 | * @throws FileNotFoundException when trying to read the file 36 | * @throws IOException when trying to read the bytes into the byte[] 37 | * @throws Exception when trying to read the bytes into the array 38 | */ 39 | public HelperFile(File file) throws FileNotFoundException, IOException, Exception { 40 | super(file.getPath()); 41 | generateBytes(); 42 | } 43 | 44 | /** 45 | * Constructor: Helpful when the file only exists in memory. 46 | * 47 | * @param bytes 48 | * @param location 49 | */ 50 | public HelperFile(byte[] bytes, String location) { 51 | super(location); 52 | this.bytes = bytes; 53 | } 54 | 55 | /** 56 | * Generates the file bytes 57 | */ 58 | private void generateBytes() throws FileNotFoundException, IOException, Exception { 59 | InputStream stream = new FileInputStream(this); 60 | if (length() > Integer.MAX_VALUE) { 61 | throw new Exception("Cannot generate bytes. File must be less than " + Integer.MAX_VALUE + " bytes."); 62 | } 63 | bytes = new byte[(int) length()]; 64 | stream.read(bytes); 65 | } 66 | 67 | /** 68 | * Saves the bytes in this HelperFile to the location in this HelperFile 69 | * 70 | * @throws FileNotFoundException if the file cannot be found 71 | * @throws IOException when writing the bytes to the disk 72 | */ 73 | public void saveBytes() throws FileNotFoundException, IOException { 74 | try (BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(this))) { 75 | out.write(bytes); 76 | } 77 | } 78 | 79 | /** 80 | * Copies this file's bytes to the given file path. Calls IOHelper.saveBytesToFile(bytes, file.getPath()); 81 | * 82 | * @param file the location of the file. 83 | * @throws FileNotFoundException if the file cannot be found 84 | * @throws IOException when writing the bytes to the disk 85 | */ 86 | public void copyBytes(File file) throws FileNotFoundException, IOException { 87 | IOHelper.saveBytesToFile(bytes, file.getPath()); 88 | } 89 | 90 | // 91 | /** 92 | * @return the bytes 93 | */ 94 | public byte[] getBytes() { 95 | return bytes; 96 | } 97 | 98 | /** 99 | * @param bytes the bytes to set 100 | */ 101 | public void setBytes(byte[] bytes) { 102 | this.bytes = bytes; 103 | } 104 | // 105 | } 106 | -------------------------------------------------------------------------------- /dist/javadoc/allclasses-noframe.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 |

All Classes

13 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /dist/javadoc/deprecated-list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Deprecated List 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Deprecated API

68 |

Contents

69 |
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/extras/LimitLinesDocumentListener.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.extras; 2 | 3 | import javax.swing.event.DocumentListener; 4 | import javax.swing.*; 5 | import javax.swing.event.*; 6 | import javax.swing.text.*; 7 | 8 | /* 9 | * A class to control the maximum number of lines to be stored in a Document 10 | * 11 | * Excess lines can be removed from the start or end of the Document depending on your requirement. 12 | * 13 | * a) if you append text to the Document, then you would want to remove lines from the start. b) if you insert 14 | * text at the beginning of the Document, then you would want to remove lines from the end. 15 | */ 16 | public class LimitLinesDocumentListener implements DocumentListener { 17 | 18 | private int maximumLines; 19 | private boolean isRemoveFromStart; 20 | 21 | /* 22 | * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start of 23 | * the Document. 24 | */ 25 | public LimitLinesDocumentListener(int maximumLines) { 26 | this(maximumLines, true); 27 | } 28 | 29 | /* 30 | * Specify the number of lines to be stored in the Document. Extra lines will be removed from the start or 31 | * end of the Document, depending on the boolean value specified. 32 | */ 33 | public LimitLinesDocumentListener(int maximumLines, boolean isRemoveFromStart) { 34 | setLimitLines(maximumLines); 35 | this.isRemoveFromStart = isRemoveFromStart; 36 | } 37 | 38 | /* 39 | * Return the maximum number of lines to be stored in the Document 40 | */ 41 | public int getLimitLines() { 42 | return maximumLines; 43 | } 44 | 45 | /* 46 | * Set the maximum number of lines to be stored in the Document 47 | */ 48 | public void setLimitLines(int maximumLines) { 49 | if (maximumLines < 1) { 50 | String message = "Maximum lines must be greater than 0"; 51 | throw new IllegalArgumentException(message); 52 | } 53 | 54 | this.maximumLines = maximumLines; 55 | } 56 | 57 | // Handle insertion of new text into the Document 58 | public void insertUpdate(final DocumentEvent e) { 59 | // Changes to the Document can not be done within the listener 60 | // so we need to add the processing to the end of the EDT 61 | 62 | SwingUtilities.invokeLater(new Runnable() { 63 | 64 | public void run() { 65 | removeLines(e); 66 | } 67 | }); 68 | } 69 | 70 | public void removeUpdate(DocumentEvent e) { 71 | } 72 | 73 | public void changedUpdate(DocumentEvent e) { 74 | } 75 | 76 | /* 77 | * Remove lines from the Document when necessary 78 | */ 79 | private void removeLines(DocumentEvent e) { 80 | // The root Element of the Document will tell us the total number 81 | // of line in the Document. 82 | 83 | Document document = e.getDocument(); 84 | Element root = document.getDefaultRootElement(); 85 | 86 | while (root.getElementCount() > maximumLines) { 87 | if (isRemoveFromStart) { 88 | removeFromStart(document, root); 89 | } else { 90 | removeFromEnd(document, root); 91 | } 92 | } 93 | } 94 | 95 | /* 96 | * Remove lines from the start of the Document 97 | */ 98 | private void removeFromStart(Document document, Element root) { 99 | Element line = root.getElement(0); 100 | int end = line.getEndOffset(); 101 | 102 | try { 103 | document.remove(0, end); 104 | } catch (BadLocationException ble) { 105 | System.out.println(ble); 106 | } 107 | } 108 | 109 | /* 110 | * Remove lines from the end of the Document 111 | */ 112 | private void removeFromEnd(Document document, Element root) { 113 | // We use start minus 1 to make sure we remove the newline 114 | // character of the previous line 115 | 116 | Element line = root.getElement(root.getElementCount() - 1); 117 | int start = line.getStartOffset(); 118 | int end = line.getEndOffset(); 119 | 120 | try { 121 | document.remove(start - 1, end - start); 122 | } catch (BadLocationException ble) { 123 | System.out.println(ble); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/StringFormatHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | /** 4 | * 5 | * @author Kent 6 | */ 7 | public class StringFormatHelper { 8 | 9 | /** 10 | * Exact code: String fixedNumber = cleanNumber(number).replace(".", ""); return 11 | * StringHelper.insertIntoString(fixedNumber, char0, "", "", char3, "", "", char6); 12 | * 13 | * @param number 14 | * @param char0 15 | * @param char3 16 | * @param char6 17 | * @return 18 | */ 19 | public static String formatPhoneNumber(String number, String char0, String char3, String char6) { 20 | String fixedNumber = NumberHelper.cleanNumber(number).replace(".", ""); 21 | return StringHelper.insertIntoString(fixedNumber, char0, "", "", char3, "", "", char6); 22 | } 23 | 24 | /** 25 | * Returns: formatPhoneNumber(number, "(", ") ", "-") which formats a number to look like this: (555) 26 | * 123-4567. Note: If you give too many numbers they'll just be added to the end of the number. Like this 27 | * (555) 123-456789101112 28 | * 29 | * @param number 30 | * @return formatted phone number 31 | */ 32 | public static String formatPhoneNumber(String number) { 33 | return formatPhoneNumber(number, "(", ") ", "-"); 34 | } 35 | 36 | /** 37 | * If the call was formatCreditCard("1234567812345678", "-") the result would be: 1234-5678-1234-5678. This 38 | * will continue if you give too long or too short of a number. If you give 12345, the result will be: 39 | * 1234-5. If you give 12345678123456789, it will return 1234-5678-1234-5678-9. NOTE: Also first calls 40 | * NumberHelper.cleanNumber(creditCard).replace(".", ""); 41 | * 42 | * @param creditCard the number string to format like a credit card number 43 | * @param separator the item to put between every 4 numbers 44 | * @return formatted credit card 45 | */ 46 | public static String formatCreditCard(String creditCard, String separator) { 47 | String fixedCreditCard = NumberHelper.cleanNumber(creditCard).replace(".", ""); 48 | char[] numbers = fixedCreditCard.toCharArray(); 49 | //1234567812345678 50 | StringBuilder sb = new StringBuilder(); 51 | for (int i = 0; i < numbers.length; i++) { 52 | if (i % 4 == 0 && i > 0) { 53 | sb.append(separator); 54 | } 55 | sb.append(numbers[i]); 56 | } 57 | return sb.toString(); 58 | } 59 | 60 | /** 61 | * This is posting something in a URL. It replaces anything in the string given with percentEncoded values 62 | * 63 | * @param originalString 64 | * @return 65 | */ 66 | public static String percentEncodeString(String originalString) { 67 | //It is important that % is first, if you put it any later it will replace % with anything that's replace before. 68 | //Try it, you'll see what I mean. 69 | java.util.Map replaceMap = new java.util.TreeMap<>(); 70 | // 71 | replaceMap.put('%', "%25"); 72 | replaceMap.put('!', "%21"); 73 | replaceMap.put('*', "%2A"); 74 | replaceMap.put('\'', "%27"); //Escape character. This value is: ' 75 | replaceMap.put('(', "%28"); 76 | replaceMap.put(')', "%29"); 77 | replaceMap.put(';', "%3B"); 78 | replaceMap.put(':', "%3A"); 79 | replaceMap.put('@', "%40"); 80 | replaceMap.put('&', "%26"); 81 | replaceMap.put('=', "%3D"); 82 | replaceMap.put('+', "%2B"); 83 | replaceMap.put('$', "%24"); 84 | replaceMap.put(',', "%2C"); 85 | replaceMap.put('/', "%2F"); 86 | replaceMap.put('?', "%3F"); 87 | replaceMap.put('#', "%23"); 88 | replaceMap.put('[', "%5B"); 89 | replaceMap.put(']', "%5D"); 90 | replaceMap.put(' ', "%20"); 91 | // 92 | char[] charArry = originalString.toCharArray(); 93 | StringBuilder fixedString = new StringBuilder(); 94 | for (int i = 0; i < charArry.length; i++) { 95 | Character c = charArry[i]; 96 | String replacement = replaceMap.get(c); 97 | if (replacement != null) { 98 | fixedString.append(replacement); 99 | } else { 100 | fixedString.append(c); 101 | } 102 | } 103 | return fixedString.toString(); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This project has been moved to BitBucket.org: https://bitbucket.org/kentcdodds/java-helper-library/overview 2 | 3 | The Java Helper Library is library of classes containing helpful methods I've found useful. I'm constantly developing on it because I'm constantly finding helpful things I use all the time when I code. I would love input from anyone who finds something that could be improved. Please let me know if you find this useful (it would really make my day). I'm super open to people contributing to this project. Please feel free to e-mail me at me@kentcdodds.com. Thanks. 4 | 5 | Notable helpful classes/methods: 6 | -IOHelper: This has Methods which make it easy to make sure a filename is filename safe (doesn't include illegal characters). There are methods to copy a resource to a file, file to a file, get the byte array of a file, get the file or resource into a String, zipping and unzipping files (in memory as well), and much more! It leverages the HelperFile to handle files in memory, so if you have files you don't want to actually save to disk, but would still like to treat as files, this can be a great help. 7 | -EmailHelper: sendEmail(service, username, password, email) is really helpful for sending e-mails with minimal code. The model package has helper classes like Email and HelperFile which allow you to send attachments even if the file itself is in memory. Support for Google, Yahoo, and Windows Live email sessions as well as the option of giving your own session with sendEmail(session, email). 8 | -StringHelper: Lots of helpful methods for manipulating strings. Have you wanted to shorten a string and add the "..." somewhere in the middle? What about wrapping a bunch of text by adding a newline after a given number of characters? Or, one of my favorites, have you wanted to split an array or list of words by a comma? It's so annoying, but this makes it really easy! Take a look. It's really helpful. 9 | -SwingHelper: Helpful methods dealing with Swing components. Center a window, resize an image, easily call a file opener/saver or a folder chooser for user interaction, work with JOptionPanes easily, and even get a window of an image (helpful for progress wheels). 10 | -NumberHelper: Ever needed to check whether input from a user is a valid number? This helper has a helpful method for that. It also helps with rounding, getting a percentage, and cleaning a number string of all non-numeric characters. 11 | -DateHelper: Difference between two dates (absolute and relative) 12 | -RandomHelper: This is mostly helpful for debugging purposes. It will generate anything from random names to random MAC addresses. Take a look. There's a lot available. If you think of anything more, let me know with an issue or contribute it yourself. 13 | -ReflectionHelper: This is good for looking into your program. You can see if an object has any fields which match a given string or print out the object and it's attributes in a logical way. 14 | -OtherHelper: Have two lists and need to remove the contents of one list from the contents of another list? Need to check whether a list or array has any null values? These methods have yet to be classified, so they're still in the OtherHelper class, but they have proven to be helpful for me. 15 | -PrinterHelper: This is helpful for debugging. Basically, the way it works is instead of Systm.out.println(), you use PrinterHelper.print() and it will only print if you've already specified PrinterHelper.setInstancePrint(true) before it's called. There's also a helpful option to open a log window where they will all be printed (this uses code from http://tips4java.wordpress.com/2008/11/08/message-console/) 16 | -StringFormatHelper: Helps you format strings like phone numbers, credit cards, and much more. 17 | -XMLHelper: Helpful methods for the XML Dom library. Create an XML document out of an xml string, transform a document into an xml string, and create an empty XML document. 18 | 19 | I'm hoping to develop this a great deal more. I welcome any (kind) input. Important: I'm not a developer with endless years of experience or anything so forgive me if some things are less than perfect. If you find something that falls short of that goal, please submit an issue and I'll look into improving it (or fork this repo and improve it yourself). Thanks! 20 | 21 | -Kent Dodds -------------------------------------------------------------------------------- /dist/javadoc/allclasses-frame.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | All Classes 8 | 9 | 10 | 11 | 12 |

All Classes

13 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/DateHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | import java.sql.Timestamp; 4 | import java.text.SimpleDateFormat; 5 | import java.util.Calendar; 6 | import java.util.Date; 7 | import java.util.TimeZone; 8 | import java.util.concurrent.TimeUnit; 9 | 10 | /** 11 | * 12 | * @author Kent 13 | */ 14 | public class DateHelper { 15 | 16 | /** 17 | * Our standard SimpleDateFormat: ("MMM d, yyyy") 18 | */ 19 | private static SimpleDateFormat dateFormatter = new SimpleDateFormat("MMM d, yyyy"); 20 | 21 | /** 22 | * Gives the difference in days between the two days. This does not round up, so, if you were to give it January 1st, 23 | * 2012 12:00:00.000 and January 2nd, 2012 11:59:59.999 it would return 0 because the milliseconds difference between 24 | * those is not full day. If you would rather have this functionality, use the getDaysDifference method. 25 | * 26 | * @param oldDate 27 | * @param recentDate 28 | * @return 29 | */ 30 | public static int getAbsoluteDaysDifference(Date oldDate, Date recentDate) { 31 | long millis = recentDate.getTime() - oldDate.getTime(); 32 | return (int) TimeUnit.MILLISECONDS.toDays(millis); 33 | } 34 | 35 | /** 36 | * Gets the days difference. This is different than getAbsoluteDaysDifference because this will not take anything 37 | * smaller than the day into account (so, for example, if you give it December 31st, 1999 at 23:59:59.999 and January 38 | * 1st, 2000 at 00:00:00.000 it will return 1, whereas getAbsoluteDaysDifference on those days would return 0 because 39 | * the actual difference between those two times is 1 millisecond 40 | * 41 | * @param oldDate 42 | * @param recentDate 43 | * @return 44 | */ 45 | public static int getDaysDifference(Date oldDate, Date recentDate) { 46 | Calendar recent = Calendar.getInstance(); 47 | recent.setTime(recentDate); 48 | 49 | Calendar old = Calendar.getInstance(); 50 | old.setTime(oldDate); 51 | 52 | int eraRecent = recent.get(Calendar.ERA); 53 | int yearRecent = recent.get(Calendar.YEAR); 54 | int dayRecent = recent.get(Calendar.DAY_OF_YEAR); 55 | 56 | int eraOld = old.get(Calendar.ERA); 57 | int yearOld = old.get(Calendar.YEAR); 58 | int dayOld = old.get(Calendar.DAY_OF_YEAR); 59 | 60 | return getDaysSinceZero(eraRecent, yearRecent, dayRecent) - getDaysSinceZero(eraOld, yearOld, dayOld); 61 | 62 | } 63 | 64 | /** 65 | * Gets the days since 0 by creating a calendar instance, setting the era and then iterating from 0 to the given year 66 | * getting the maximum day of the year for each of those years and adding that number until finally it reaches the 67 | * year given and then adds the dayOfYear given. Returns negative if the era != 1; (which is AD) 68 | * 69 | * @param era 70 | * @param yearOfEra 71 | * @param dayOfYear 72 | * @return 73 | */ 74 | public static int getDaysSinceZero(int era, int yearOfEra, int dayOfYear) { 75 | int days = 0; 76 | Calendar cal = Calendar.getInstance(); 77 | cal.set(Calendar.ERA, era); 78 | for (int i = 0; i < yearOfEra; i++) { 79 | cal.set(Calendar.YEAR, i); 80 | days += cal.getActualMaximum(Calendar.DAY_OF_YEAR); 81 | } 82 | days += dayOfYear; 83 | return (era == 1) ? days : -days; 84 | } 85 | 86 | /** 87 | * Converts a long time in nanoseconds to a formatted timestamp. Useful for timing operations. Simply use long begin = 88 | * System.nanoTime(); ...some operation... long end = System.nanoTime(); nanoToString(end - begin); 89 | * 90 | * @param nanoseconds 91 | * @return 92 | */ 93 | public static String nanosecondsToString(long nanoseconds) { 94 | Timestamp ts = new Timestamp(TimeUnit.MILLISECONDS.convert(nanoseconds, TimeUnit.NANOSECONDS)); 95 | SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss:SSS"); 96 | format.setTimeZone(TimeZone.getTimeZone("UTC")); 97 | return format.format(ts); 98 | } 99 | 100 | /** 101 | * @return the dateFormatter. Default is ("MMM d, yyyy"). 102 | */ 103 | public static SimpleDateFormat getDateFormatter() { 104 | return dateFormatter; 105 | } 106 | 107 | /** 108 | * @param aDateFormatter the dateFormatter to set. Default is ("MMM d, yyyy"). 109 | */ 110 | public static void setDateFormatter(SimpleDateFormat aDateFormatter) { 111 | dateFormatter = aDateFormatter; 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/SQLHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | import au.com.bytecode.opencsv.CSVWriter; 4 | import com.kentcdodds.javahelper.model.HelperConnection; 5 | import com.kentcdodds.javahelper.model.HelperQuery; 6 | import com.kentcdodds.javahelper.model.QueryParameter; 7 | import java.io.File; 8 | import java.io.FileNotFoundException; 9 | import java.io.IOException; 10 | import java.io.PrintWriter; 11 | import java.sql.ResultSet; 12 | import java.sql.ResultSetMetaData; 13 | import java.sql.SQLException; 14 | import java.util.Map; 15 | 16 | /** 17 | * 18 | * @author kentcdodds 19 | */ 20 | public class SQLHelper { 21 | 22 | /** 23 | * Creates a new HelperConnection and executes a new HelperQuery. Useful for when you don't care to keep the 24 | * HelperConnection or HelperQuery for processing later. 25 | * 26 | * @param connectionUrl the url to use to create the connection 27 | * @param properties the properties to apply to the connection 28 | * @param query the query to execute 29 | * @param params the parameters to add to the prepared statement created by connection and query 30 | * @return the results of helperQuery.execute(); 31 | * @throws SQLException 32 | */ 33 | public static ResultSet executeQuery(String connectionUrl, Map properties, String query, QueryParameter... params) throws SQLException { 34 | return new HelperConnection(connectionUrl, properties).executeQuery(new HelperQuery(query, params)); 35 | } 36 | 37 | /** 38 | * Creates a HelperQuery out of the given HelperConnection, query, and params and calls helperQuery.execute(); 39 | * 40 | * @param helperConnection the HelperConnection to run the query with 41 | * @param query the query to be run 42 | * @param params the parameters to apply to the statement created by the query and the connection 43 | * @return the results of helperQuery.execute(); 44 | * @throws DataException 45 | * @throws SQLException 46 | */ 47 | public static ResultSet executeQuery(HelperConnection helperConnection, String query, QueryParameter... params) throws SQLException { 48 | HelperQuery helperQuery = new HelperQuery(query, params); 49 | return helperConnection.executeQuery(helperQuery); 50 | } 51 | 52 | /** 53 | * Prints the result set to the consol. 54 | * @param rs 55 | * @throws SQLException 56 | */ 57 | public static void printResultSet(ResultSet rs) throws SQLException { 58 | ResultSetMetaData metaData = rs.getMetaData(); 59 | int columnCount = metaData.getColumnCount(); 60 | String[] header = new String[columnCount]; 61 | for (int i = 0; i < columnCount; i++) { 62 | header[i] = metaData.getColumnName(i + 1); 63 | } 64 | PrinterHelper.println(StringHelper.splitBy("\t", header)); 65 | while (rs.next()) { 66 | String[] row = new String[columnCount]; 67 | for (int i = 0; i < columnCount; i++) { 68 | String string = rs.getString(i + 1); 69 | if (string == null) { 70 | string = ""; 71 | } 72 | row[i] = string; 73 | } 74 | PrinterHelper.println(StringHelper.splitBy("\t", row)); 75 | } 76 | } 77 | 78 | /** 79 | * Prints the given ResultSet to a comma separated file (the destination) 80 | * 81 | * @param rs 82 | * @param destination 83 | * @throws SQLException 84 | * @throws FileNotFoundException 85 | */ 86 | public static void resultSetToCSVFile(ResultSet rs, String destination) throws SQLException, FileNotFoundException, IOException { 87 | ResultSetMetaData metaData = rs.getMetaData(); 88 | int columnCount = metaData.getColumnCount(); 89 | String[] header = new String[columnCount]; 90 | for (int i = 0; i < columnCount; i++) { 91 | header[i] = metaData.getColumnName(i + 1); 92 | } 93 | File file = new File(destination); 94 | IOHelper.checkDirectory(file); 95 | try (PrintWriter pw = new PrintWriter(file); CSVWriter writer = new CSVWriter(pw)) { 96 | writer.writeNext(header); 97 | while (rs.next()) { 98 | String[] row = new String[columnCount]; 99 | for (int i = 0; i < columnCount; i++) { 100 | String string = rs.getString(i + 1); 101 | if (string == null) { 102 | string = ""; 103 | } 104 | row[i] = string; 105 | } 106 | writer.writeNext(row); 107 | } 108 | } 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/test/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Package com.kentcdodds.javahelper.test 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Package
com.kentcdodds.javahelper.test

68 |
69 |
No usage of com.kentcdodds.javahelper.test
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/extras/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Package com.kentcdodds.javahelper.extras 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Package
com.kentcdodds.javahelper.extras

68 |
69 |
No usage of com.kentcdodds.javahelper.extras
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/serialized-form.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Serialized Form 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Serialized Form

68 |
69 |
70 | 95 |
96 | 97 |
98 | 99 | 100 | 101 | 102 | 112 |
113 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/test/class-use/TestClass.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.test.TestClass 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.test.TestClass

68 |
69 |
No usage of com.kentcdodds.javahelper.test.TestClass
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/IOHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.IOHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.IOHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.IOHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/test/class-use/TestArchive.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.test.TestArchive 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.test.TestArchive

68 |
69 |
No usage of com.kentcdodds.javahelper.test.TestArchive
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/SQLHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.SQLHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.SQLHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.SQLHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/XMLHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.XMLHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.XMLHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.XMLHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/DateHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.DateHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.DateHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.DateHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/DebugHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.DebugHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.DebugHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.DebugHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/EmailHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.EmailHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.EmailHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.EmailHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/OtherHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.OtherHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.OtherHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.OtherHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/SwingHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.SwingHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.SwingHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.SwingHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/NumberHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.NumberHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.NumberHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.NumberHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/RandomHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.RandomHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.RandomHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.RandomHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/StringHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.StringHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.StringHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.StringHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/extras/class-use/MessageConsole.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.extras.MessageConsole 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.extras.MessageConsole

68 |
69 |
No usage of com.kentcdodds.javahelper.extras.MessageConsole
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/ReflectionHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.ReflectionHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.ReflectionHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.ReflectionHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/class-use/StringFormatHelper.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.helpers.StringFormatHelper 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.helpers.StringFormatHelper

68 |
69 |
No usage of com.kentcdodds.javahelper.helpers.StringFormatHelper
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/extras/class-use/LimitLinesDocumentListener.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Class com.kentcdodds.javahelper.extras.LimitLinesDocumentListener 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Class
com.kentcdodds.javahelper.extras.LimitLinesDocumentListener

68 |
69 |
No usage of com.kentcdodds.javahelper.extras.LimitLinesDocumentListener
70 | 71 |
72 | 73 | 74 | 75 | 76 | 86 |
87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /dist/javadoc/overview-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Overview 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 |
Packages 
PackageDescription
com.kentcdodds.javahelper.extras 
com.kentcdodds.javahelper.helpers 
com.kentcdodds.javahelper.model 
com.kentcdodds.javahelper.test 
92 |
93 | 94 |
95 | 96 | 97 | 98 | 99 | 109 |
110 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/test/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.test Class Hierarchy 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Hierarchy For Package com.kentcdodds.javahelper.test

68 | Package Hierarchies: 69 | 72 |
73 |
74 |

Class Hierarchy

75 |
    76 |
  • java.lang.Object 77 |
      78 |
    • com.kentcdodds.javahelper.test.TestArchive
    • 79 |
    • com.kentcdodds.javahelper.test.TestClass
    • 80 |
    81 |
  • 82 |
83 |
84 | 85 |
86 | 87 | 88 | 89 | 90 | 100 |
101 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/extras/package-tree.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.extras Class Hierarchy 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Hierarchy For Package com.kentcdodds.javahelper.extras

68 | Package Hierarchies: 69 | 72 |
73 |
74 |

Class Hierarchy

75 |
    76 |
  • java.lang.Object 77 | 81 |
  • 82 |
83 |
84 | 85 |
86 | 87 | 88 | 89 | 90 | 100 |
101 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/test/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.test 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Package com.kentcdodds.javahelper.test

68 |
69 |
70 |
    71 |
  • 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 |
    Class Summary 
    ClassDescription
    TestArchive 
    TestClass 
    89 |
  • 90 |
91 |
92 | 93 |
94 | 95 | 96 | 97 | 98 | 108 |
109 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/extras/package-summary.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | com.kentcdodds.javahelper.extras 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Package com.kentcdodds.javahelper.extras

68 |
69 |
70 | 91 |
92 | 93 |
94 | 95 | 96 | 97 | 98 | 108 |
109 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /dist/javadoc/index-files/index-22.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Y-Index 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
A B C D E F G H I L M N O P Q R S T U W X Y Z  67 | 68 | 69 |

Y

70 |
71 |
YAHOO - Static variable in class com.kentcdodds.javahelper.helpers.EmailHelper
72 |
 
73 |
74 | A B C D E F G H I L M N O P Q R S T U W X Y Z 
75 | 76 |
77 | 78 | 79 | 80 | 81 | 91 |
92 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /src/com/kentcdodds/javahelper/helpers/PrinterHelper.java: -------------------------------------------------------------------------------- 1 | package com.kentcdodds.javahelper.helpers; 2 | 3 | import com.kentcdodds.javahelper.extras.MessageConsole; 4 | import java.awt.Color; 5 | import java.io.PrintStream; 6 | import javax.swing.JDialog; 7 | import javax.swing.JScrollPane; 8 | import javax.swing.JTextPane; 9 | 10 | /** 11 | * Good for debugging, this class allows you to send your prints somewhere and change whether it all prints. Sometimes 12 | * you want to reduce the amount your code prints to isolate a problem. This way you just set the PrintHelper 13 | * instance.setPrint(true) and it'll print everything you send to the printALot method. 14 | * 15 | * @author Kent 16 | */ 17 | public class PrinterHelper { 18 | 19 | private boolean print = false; 20 | private JDialog outputDialog = new JDialog(); 21 | private JTextPane textPane = new JTextPane(); 22 | private final PrintStream originalOut = System.out; 23 | private final PrintStream originalErr = System.err; 24 | private static PrinterHelper instance; 25 | 26 | private PrinterHelper() { 27 | textPane.setPreferredSize(new java.awt.Dimension(450, 200)); 28 | JScrollPane scrollPane = new JScrollPane(textPane); 29 | scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); 30 | scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); 31 | scrollPane.setPreferredSize(new java.awt.Dimension( 32 | (textPane.getPreferredSize().width + 20), textPane.getPreferredSize().height)); 33 | outputDialog.getContentPane().add(scrollPane); 34 | SwingHelper.centerAndPack(outputDialog); 35 | outputDialog.addWindowListener(new java.awt.event.WindowAdapter() { 36 | 37 | @Override 38 | public void windowClosing(java.awt.event.WindowEvent evt) { 39 | System.setErr(getInstance().getOriginalErr()); 40 | System.setOut(getInstance().getOriginalOut()); 41 | } 42 | }); 43 | } 44 | 45 | public static PrinterHelper getInstance() { 46 | if (instance == null) { 47 | instance = new PrinterHelper(); 48 | } 49 | return instance; 50 | } 51 | 52 | // 53 | /** 54 | * Prints the given String if the print variable is true 55 | * 56 | * @param object to print 57 | */ 58 | public static void print(Object object) { 59 | if (getInstance().isPrint()) { 60 | System.out.print(object); 61 | } 62 | } 63 | 64 | /** 65 | * Prints the given String followed by a new line if the print variable is true 66 | * 67 | * @param object to print 68 | */ 69 | public static void println(Object object) { 70 | if (getInstance().isPrint()) { 71 | System.out.println(object); 72 | } 73 | } 74 | 75 | /** 76 | * Prints a new line if Print on the current instance is true 77 | */ 78 | public static void println() { 79 | if (getInstance().isPrint()) { 80 | System.out.println(); 81 | } 82 | } 83 | // 84 | 85 | // 86 | /** 87 | * Prints the given String in error type if the print variable is true 88 | * 89 | * @param object to print 90 | */ 91 | public static void printErr(Object object) { 92 | if (getInstance().isPrint()) { 93 | System.err.print(object); 94 | } 95 | } 96 | 97 | /** 98 | * Prints the given String followed by a newline in error type if the print variable is true 99 | * 100 | * @param object to print 101 | */ 102 | public static void printErrln(Object object) { 103 | if (getInstance().isPrint()) { 104 | System.err.println(object); 105 | } 106 | } 107 | 108 | /** 109 | * Prints a new error line if Print on the current instance is true 110 | */ 111 | public static void printErrln() { 112 | if (getInstance().isPrint()) { 113 | System.err.println(); 114 | } 115 | } 116 | // 117 | 118 | /** 119 | * Convenience method. sets the dialog title and then calls showMessageConsole() 120 | * 121 | * @param dialogTitle 122 | */ 123 | public static void showMessageConsole(String dialogTitle) { 124 | getInstance().getOutputDialog().setTitle(dialogTitle); 125 | if (getInstance().getOutputDialog().isVisible()) { 126 | return; 127 | } 128 | MessageConsole mc = new MessageConsole(getInstance().getTextArea()); 129 | mc.redirectOut(); 130 | mc.redirectErr(Color.red, null); 131 | mc.setMessageLines(10000); 132 | getInstance().getOutputDialog().setVisible(true); 133 | } 134 | 135 | /** 136 | * Shows the output window and sends all messages sent to PrintHelper via print methods to this window as well. 137 | */ 138 | public static void showMessageConsole() { 139 | showMessageConsole(getInstance().getOutputDialog().getTitle()); 140 | } 141 | 142 | /** 143 | * @return the print 144 | */ 145 | public boolean isPrint() { 146 | return print; 147 | } 148 | 149 | /** 150 | * @param print 151 | */ 152 | public void setPrint(boolean print) { 153 | this.print = print; 154 | } 155 | 156 | /** 157 | * Calls setPrint on the instance of the printerhelper 158 | * 159 | * @param print 160 | */ 161 | public static void setInstancePrint(boolean print) { 162 | getInstance().setPrint(print); 163 | } 164 | 165 | /** 166 | * @return the outputDialog 167 | */ 168 | public JDialog getOutputDialog() { 169 | return outputDialog; 170 | } 171 | 172 | /** 173 | * @param outputDialog the outputDialog to set 174 | */ 175 | public void setOutputDialog(JDialog outputDialog) { 176 | this.outputDialog = outputDialog; 177 | } 178 | 179 | /** 180 | * @return the originalOut 181 | */ 182 | public PrintStream getOriginalOut() { 183 | return originalOut; 184 | } 185 | 186 | /** 187 | * @return the originalErr 188 | */ 189 | public PrintStream getOriginalErr() { 190 | return originalErr; 191 | } 192 | 193 | /** 194 | * @return the textArea 195 | */ 196 | public JTextPane getTextArea() { 197 | return textPane; 198 | } 199 | 200 | /** 201 | * @param textArea the textArea to set 202 | */ 203 | public void setTextPane(JTextPane textArea) { 204 | this.textPane = textArea; 205 | } 206 | } 207 | -------------------------------------------------------------------------------- /dist/javadoc/com/kentcdodds/javahelper/helpers/package-use.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Uses of Package com.kentcdodds.javahelper.helpers 8 | 9 | 10 | 11 | 12 | 18 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 37 |
38 | 65 | 66 |
67 |

Uses of Package
com.kentcdodds.javahelper.helpers

68 |
69 |
70 | 104 |
105 | 106 |
107 | 108 | 109 | 110 | 111 | 121 |
122 | 149 | 150 | 151 | 152 | --------------------------------------------------------------------------------