1 11 package org.eclipse.pde.internal.builders; 12 13 import org.eclipse.osgi.util.ManifestElement; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.pde.internal.PDEMessages; 16 import org.osgi.framework.BundleException; 17 18 public class JarManifestHeader implements IHeader { 19 private JarManifestErrorReporter fErrorReporter; 20 21 private int fLineNumber; 22 23 private int fLines; 24 25 private ManifestElement[] fManifestElements; 26 27 private String fName; 28 29 private String fValue; 30 31 39 public JarManifestHeader(String name, String value, int lineNumber, 40 JarManifestErrorReporter errorReporter) { 41 fName = name; 42 fValue = value; 43 fLineNumber = lineNumber; 44 fErrorReporter = errorReporter; 45 fLines = 1; 46 } 47 48 public void append(String value) { 49 fValue += value; 50 fLines++; 51 } 52 53 public ManifestElement[] getElements() { 54 if (fManifestElements == null) { 55 if (getValue().trim().length() > 0) { 56 try { 57 fManifestElements = ManifestElement.parseHeader(getName(), 58 getValue()); 59 } catch (BundleException be) { 60 fManifestElements = new ManifestElement[0]; 61 if (fErrorReporter != null) { 62 String message = NLS.bind(PDEMessages.BundleErrorReporter_parseHeader, getName()); fErrorReporter.report(message, getLineNumber() + 1, 64 CompilerFlags.ERROR); 65 } 66 } 67 } else { 68 fManifestElements = new ManifestElement[0]; 69 } 70 } 71 return fManifestElements; 72 } 73 74 public int getLineNumber() { 75 return fLineNumber; 76 } 77 78 public int getLinesSpan() { 79 return fLines; 80 } 81 82 public String getName() { 83 return fName; 84 } 85 86 public String getValue() { 87 return fValue; 88 } 89 90 public String toString() { 91 return fName + "=" + fValue; } 93 94 } 95 | Popular Tags |