1 11 package org.eclipse.core.runtime.model; 12 13 import org.eclipse.core.runtime.Assert; 14 15 25 26 public abstract class PluginModelObject { 27 28 private String name = null; 30 31 private int flags = 0; 33 static final int M_READ_ONLY = 0x80000000; 40 41 45 protected void assertIsWriteable() { 46 Assert.isTrue(!isReadOnly(), "Model is read-only"); } 48 49 54 public String getName() { 55 return name; 56 } 57 58 64 public int getStartLine() { 65 return (flags & ~M_READ_ONLY) - 1; 66 } 67 68 75 public boolean isReadOnly() { 76 return (flags & M_READ_ONLY) == M_READ_ONLY; 77 } 78 79 85 public void markReadOnly() { 86 flags |= M_READ_ONLY; 87 } 88 89 95 public void setLocalizedName(String value) { 96 name = value; 97 } 98 99 104 public void setName(String value) { 105 assertIsWriteable(); 106 name = value; 107 } 108 109 117 public void setStartLine(int lineNumber) { 118 if (getStartLine() == -1) 119 flags = (lineNumber + 1) | (flags & M_READ_ONLY); 120 } 121 122 128 public String toString() { 129 return this.getClass() + "(" + getName() + ")"; } 131 } 132 | Popular Tags |