1 21 22 package org.armedbear.j; 23 24 import java.io.BufferedWriter ; 25 import java.io.IOException ; 26 import java.io.Writer ; 27 import java.util.List ; 28 29 public abstract class Tagger implements Constants, Runnable 30 { 31 public static final char separatorChar = 0; 32 33 protected SystemBuffer buffer; 34 35 protected Tagger(SystemBuffer buffer) 36 { 37 this.buffer = buffer; 38 } 39 40 public void writeTags(Writer writer) 41 { 42 if (buffer == null) 43 return; 44 List tags = buffer.getTags(); 45 if (tags == null) 46 return; 47 File file = buffer.getFile(); 48 if (file == null) 49 return; 50 final String canonicalPath = file.canonicalPath(); 51 try { 52 for (int i = 0, limit = tags.size(); i < limit; i++) { 53 LocalTag localTag = (LocalTag) tags.get(i); 54 if (localTag != null) { 55 switch (localTag.getType()) { 56 case TAG_INTERFACE: 57 case TAG_CLASS: 58 case TAG_METHOD: 59 case TAG_EXPLICIT: 60 case TAG_DEFUN: case TAG_GENERIC_FUNCTION: case TAG_MACRO: case TAG_STRUCT: writer.write(localTag.getName()); 65 writer.write(separatorChar); 66 writer.write(canonicalPath); 67 writer.write(separatorChar); 68 writer.write(localTag.getLine().getText()); 69 final String canonicalSignature = 70 localTag.getCanonicalSignature(); 71 if (canonicalSignature != null) { 72 writer.write(separatorChar); 73 writer.write(canonicalSignature); 74 } 75 writer.write('\n'); 76 break; 77 default: 78 break; 79 } 80 } 81 } 82 writer.flush(); 83 } 84 catch (IOException e) { 85 Log.error(e); 86 } 87 } 88 89 public abstract void run(); 90 } 91 | Popular Tags |