1 package com.puppycrawl.tools.checkstyle.checks.indentation; 20 21 import java.util.Iterator ; 22 import java.util.SortedSet ; 23 import java.util.TreeSet ; 24 25 31 public class IndentLevel 32 { 33 34 private final SortedSet mLevels = new TreeSet (); 35 36 40 public IndentLevel(int aIndent) 41 { 42 mLevels.add(new Integer (aIndent)); 43 } 44 45 50 public IndentLevel(IndentLevel aBase, int aOffset) 51 { 52 for (final Iterator iter = aBase.mLevels.iterator(); iter.hasNext();) { 53 final int base = ((Integer ) iter.next()).intValue(); 54 mLevels.add(new Integer (base + aOffset)); 55 } 56 } 57 58 62 public final boolean isMultiLevel() 63 { 64 return mLevels.size() > 1; 65 } 66 67 73 public boolean accept(int aIndent) 74 { 75 return (mLevels.contains(new Integer (aIndent))); 76 } 77 78 83 public boolean gt(int aIndent) 84 { 85 return (((Integer ) mLevels.first()).intValue() > aIndent); 86 } 87 88 92 public void addAcceptedIndent(int aIndent) 93 { 94 mLevels.add(new Integer (aIndent)); 95 } 96 97 101 public void addAcceptedIndent(IndentLevel aIndent) 102 { 103 mLevels.addAll(aIndent.mLevels); 104 } 105 106 107 public String toString() 108 { 109 if (mLevels.size() == 1) { 110 return mLevels.first().toString(); 111 } 112 113 return mLevels.toString(); 114 } 115 } 116 | Popular Tags |