1 22 23 package org.gjt.sp.jedit.buffer; 24 25 import java.util.*; 26 import javax.swing.text.Segment ; 27 import org.gjt.sp.jedit.ServiceManager; 28 import org.gjt.sp.util.StandardUtilities; 29 30 46 public abstract class FoldHandler 47 { 48 52 public static final String SERVICE = "org.gjt.sp.jedit.buffer.FoldHandler"; 53 54 60 public String getName() 61 { 62 return name; 63 } 64 66 76 public abstract int getFoldLevel(JEditBuffer buffer, int lineIndex, Segment seg); 77 79 84 public boolean equals(Object o) 85 { 86 if(o == null) 88 return false; 89 else 90 return getClass() == o.getClass(); 91 } 93 public int hashCode() 95 { 96 return getClass().hashCode(); 97 } 99 106 public static FoldHandler getFoldHandler(String name) 107 { 108 FoldHandler handler = (FoldHandler)ServiceManager 109 .getService(SERVICE,name); 110 return handler; 111 } 112 114 121 public static String [] getFoldModes() 122 { 123 String [] handlers = ServiceManager.getServiceNames(SERVICE); 124 Arrays.sort(handlers,new StandardUtilities.StringCompare()); 125 return handlers; 126 } 127 129 protected FoldHandler(String name) 131 { 132 this.name = name; 133 } 134 136 public String toString() 138 { 139 return name; 140 } 142 private String name; 143 } 144 | Popular Tags |