Skip to content

Commit

Permalink
cleaned up .classpath and re-added resources folder.
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvio Heuberger committed Sep 12, 2009
1 parent cf980bc commit 2f8d0e0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
7 changes: 2 additions & 5 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="test"/>
<classpathentry kind="src" path="bench"/>
<classpathentry kind="lib" path="lib/jdom.jar">
<attributes>
<attribute name="javadoc_location" value="file:/home/kungfoo/downloads/jdom/build/apidocs/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/jdom.jar" />
<classpathentry kind="lib" path="lib/jcodings.jar"/>
<classpathentry kind="lib" path="lib/joni.jar"/>
<classpathentry kind="lib" path="lib/junit-4.7.jar"/>
Expand All @@ -21,5 +17,6 @@
<classpathentry kind="lib" path="lib/org.eclipse.text_3.5.0.v20090513-2000.jar"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="var" path="SWT_JAR"/>
<classpathentry kind="src" path="resources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
44 changes: 22 additions & 22 deletions src/com/redcareditor/plist/Dict.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,24 @@
*/
public class Dict extends PlistNode<Map<String, PlistNode<?>>> {

public static class EntityResolver implements org.xml.sax.EntityResolver {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
if (systemId.equals("http://www.apple.com/DTDs/PropertyList-1.0.dtd")) {
InputStream is = EntityResolver.class.getClassLoader().getResourceAsStream("PropertyList-1.0.dtd");
return new InputSource(is);
}
return null;
}
}
public static class EntityResolver implements org.xml.sax.EntityResolver {
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
if (systemId.equals("http://www.apple.com/DTDs/PropertyList-1.0.dtd")) {
InputStream is = EntityResolver.class.getClassLoader().getResourceAsStream("PropertyList-1.0.dtd");
return new InputSource(is);
}
return null;
}
}

public static Dict parseFile(String filename) {
SAXBuilder builder;
Document document;
builder = new SAXBuilder();
builder.setEntityResolver(new EntityResolver());
try {
document = builder.build(new File(filename));

SAXBuilder builder = new SAXBuilder();
builder.setEntityResolver(new EntityResolver());
Document document = builder.build(new File(filename));
return new Dict(document.getRootElement().getChild("dict"));

} catch (JDOMException e) {
e.printStackTrace();
} catch (IOException e) {
Expand Down Expand Up @@ -71,7 +71,7 @@ public String getString(String key) {
public Integer getInt(String key) {
return tryGettingValue(this, key);
}

@SuppressWarnings("unchecked")
public String[] getStrings(String key) {
List<PlistNode<String>> strings = (List<PlistNode<String>>) value.get(key).value;
Expand All @@ -92,26 +92,26 @@ public Dict[] getDictionaries(String key) {
public List<PlistNode<?>> getArray(String key) {
return tryGettingValue(this, key);
}

public Dict getDictionary(String key) {
return (Dict) value.get(key);
}
public Rx getRegExp(String key){

public Rx getRegExp(String key) {
return Rx.createRx(getString(key));
}

public boolean containsElement(String key) {
return value.containsKey(key);
}

public Set<String> keys() {
return value.keySet();
}

@SuppressWarnings("unchecked")
private static <T> T tryGettingValue(Dict dict, String key){
if(dict.value.containsKey(key)){
private static <T> T tryGettingValue(Dict dict, String key) {
if (dict.value.containsKey(key)) {
return (T) dict.value.get(key).value;
} else {
return null;
Expand Down
2 changes: 0 additions & 2 deletions test/com/redcareditor/mate/GrammarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import org.junit.Before;
import org.junit.Test;

import com.redcareditor.plist.Dict;

public class GrammarTest {
private Grammar g;

Expand Down

0 comments on commit 2f8d0e0

Please sign in to comment.