1 11 package org.eclipse.pde.internal.core.builders; 12 13 import org.eclipse.osgi.util.ManifestElement; 14 import org.eclipse.osgi.util.NLS; 15 import org.eclipse.pde.internal.core.PDECoreMessages; 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(PDECoreMessages.BundleErrorReporter_parseHeader, getName()); 63 fErrorReporter.report(message, getLineNumber() + 1, 64 CompilerFlags.ERROR, 65 PDEMarkerFactory.CAT_FATAL); 66 } 67 } 68 } else { 69 fManifestElements = new ManifestElement[0]; 70 } 71 } 72 return fManifestElements; 73 } 74 75 public int getLineNumber() { 76 return fLineNumber; 77 } 78 79 public int getLinesSpan() { 80 return fLines; 81 } 82 83 public String getName() { 84 return fName; 85 } 86 87 public String getValue() { 88 return fValue; 89 } 90 91 public String toString() { 92 return fName + "=" + fValue; } 94 95 } 96 | Popular Tags |