1 package com.puppycrawl.tools.checkstyle.checks; 20 21 import java.util.Map ; 22 import java.util.HashMap ; 23 24 30 public final class LineSeparatorOption extends AbstractOption 31 { 32 33 private static final Map STR_TO_OPT = new HashMap (); 34 35 36 public static final LineSeparatorOption CRLF = 37 new LineSeparatorOption("crlf", "\r\n"); 38 39 40 public static final LineSeparatorOption CR = 41 new LineSeparatorOption("cr", "\r"); 42 43 44 public static final LineSeparatorOption LF = 45 new LineSeparatorOption("lf", "\n"); 46 47 48 public static final LineSeparatorOption SYSTEM = new LineSeparatorOption( 49 "system", System.getProperty("line.separator")); 50 51 52 private final String mLineSeparator; 53 54 59 private LineSeparatorOption(String aStrRep, String aSep) 60 { 61 super(aStrRep); 62 mLineSeparator = aSep; 63 } 64 65 70 public boolean matches(byte[] aBytes) 71 { 72 final String s = new String (aBytes); 73 return s.equals(mLineSeparator); 74 } 75 76 80 public int length() 81 { 82 return mLineSeparator.length(); 83 } 84 85 86 protected Map getStrToOpt() 87 { 88 return STR_TO_OPT; 89 } 90 91 } 92 | Popular Tags |