001package Torello.JavaDoc.SyntaxHiLite; 002 003import Torello.Java.ParallelArrayException; 004import Torello.HTML.TagNode; 005 006import java.util.Arrays; 007 008public class AbstractHiLiter implements java.io.Serializable 009{ 010 protected static final long serialVersionUID = 1; 011 012 013 // ******************************************************************************************** 014 // ******************************************************************************************** 015 // Instance Fields 016 // ******************************************************************************************** 017 // ******************************************************************************************** 018 019 020 protected final TagNode[] openers; 021 protected final TagNode[] closers; 022 protected final boolean[] utilize; 023 024 protected final int CONFIG_ARR_LEN; 025 026 027 // ******************************************************************************************** 028 // ******************************************************************************************** 029 // Constructor 030 // ******************************************************************************************** 031 // ******************************************************************************************** 032 033 034 protected AbstractHiLiter( 035 final TagNode[] openers, 036 final TagNode[] closers, 037 final boolean[] utilize 038 ) 039 { 040 ParallelArrayException.check(openers, "openers", closers, "closers"); 041 ParallelArrayException.check(closers, "closers", utilize, "utilize"); 042 043 this.openers = openers; 044 this.closers = closers; 045 this.utilize = utilize; 046 047 this.CONFIG_ARR_LEN = openers.length; 048 } 049 050 051 // ******************************************************************************************** 052 // ******************************************************************************************** 053 // Retrieval / Getter Methods 054 // ******************************************************************************************** 055 // ******************************************************************************************** 056 057 058 public TagNode getOpeningTag(byte whichOne) 059 { 060 checkWhichOne(whichOne); 061 return openers[whichOne]; 062 } 063 064 public TagNode getClosingTag(byte whichOne) 065 { 066 checkWhichOne(whichOne); 067 return closers[whichOne]; 068 } 069 070 public boolean getUtilized(byte whichOne) 071 { 072 checkWhichOne(whichOne); 073 return utilize[whichOne]; 074 } 075 076 private void checkWhichOne(byte whichOne) 077 { 078 if ((whichOne < 1) || (whichOne >= this.CONFIG_ARR_LEN)) 079 080 throw new IllegalArgumentException( 081 "You have passed an invalid value [" + whichOne + "], to parameter 'whichOne'. " + 082 "This must be a valid byte, whose value is between 1 and " + 083 (this.CONFIG_ARR_LEN - 1) 084 ); 085 } 086 087 088 // ******************************************************************************************** 089 // ******************************************************************************************** 090 // java.lang.Object 091 // ******************************************************************************************** 092 // ******************************************************************************************** 093 094 095 public boolean equals(Object other) 096 { 097 if (! (other instanceof AbstractHiLiter)) return false; 098 099 AbstractHiLiter o = (AbstractHiLiter) other; 100 101 return 102 Arrays.equals(this.openers, o.openers) 103 && Arrays.equals(this.closers, o.closers) 104 && Arrays.equals(this.utilize, o.utilize); 105 } 106 107 public int hashCode() 108 { return Arrays.hashCode(this.openers); } 109}