View Javadoc

1   package org.peaseplate;
2   
3   public enum LineSeparator {
4   	NONE(""),
5   	UNIX("\n"),
6   	DOS("\r\n"),
7   	MAC("\r");
8   	
9   	final String separator;
10  	
11  	private LineSeparator(String separator) {
12  		this.separator = separator;
13  	}
14  
15  	/**
16  	 * @see java.lang.Enum#toString()
17  	 */
18  	@Override
19  	public String toString() {
20  		return separator;
21  	}
22  	
23  	public static LineSeparator get(String separator) {
24  		if (NONE.toString().equals(separator))
25  			return NONE;
26  		
27  		if (UNIX.toString().equals(separator))
28  			return UNIX;
29  		
30  		if (DOS.toString().equals(separator))
31  			return DOS;
32  		
33  		if (MAC.toString().equals(separator))
34  			return MAC;
35  		
36  		return null;
37  	}
38  	
39  }