Skip to content

Commit 803c00a

Browse files
jvpratJordi Vilalta Prat
authored andcommitted
Add wrappers for file references and groups.
1 parent df4ff8f commit 803c00a

4 files changed

Lines changed: 187 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* #%L
3+
* xcode-project-reader
4+
* %%
5+
* Copyright (C) 2012 SAP AG
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.sap.prd.mobile.ios.mios.xcodeprojreader.treeelements;
21+
22+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.Dict;
23+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.ProjectFile;
24+
25+
public class PBXFileReference extends TreeElement {
26+
27+
public PBXFileReference(ProjectFile projectFile)
28+
{
29+
this(projectFile, projectFile.createDict());
30+
}
31+
32+
public PBXFileReference(ProjectFile projectFile, Dict dict)
33+
{
34+
super(projectFile, dict);
35+
}
36+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* #%L
3+
* xcode-project-reader
4+
* %%
5+
* Copyright (C) 2012 SAP AG
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.sap.prd.mobile.ios.mios.xcodeprojreader.treeelements;
21+
22+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.Dict;
23+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.ElementFactory;
24+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.ProjectFile;
25+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.ReferenceArray;
26+
27+
public class PBXGroup extends TreeElement {
28+
29+
public PBXGroup(ProjectFile projectFile)
30+
{
31+
this(projectFile, projectFile.createDict());
32+
}
33+
34+
public PBXGroup(ProjectFile projectFile, Dict dict)
35+
{
36+
super(projectFile, dict);
37+
}
38+
39+
public ReferenceArray<TreeElement> getChildren()
40+
{
41+
return new ReferenceArray<TreeElement>(getProjectFile(), getDict().getOrCreateAndSetArray("children"),
42+
new ElementFactory<TreeElement>() {
43+
@Override
44+
public TreeElement create(ProjectFile projectFile, Dict dict) {
45+
return TreeElement.create(projectFile, dict);
46+
}
47+
});
48+
}
49+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* #%L
3+
* xcode-project-reader
4+
* %%
5+
* Copyright (C) 2012 SAP AG
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.sap.prd.mobile.ios.mios.xcodeprojreader.treeelements;
21+
22+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.Dict;
23+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.ProjectFile;
24+
25+
public class PBXVariantGroup extends PBXGroup {
26+
27+
public PBXVariantGroup(ProjectFile projectFile)
28+
{
29+
this(projectFile, projectFile.createDict());
30+
}
31+
32+
public PBXVariantGroup(ProjectFile projectFile, Dict dict)
33+
{
34+
super(projectFile, dict);
35+
}
36+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* #%L
3+
* xcode-project-reader
4+
* %%
5+
* Copyright (C) 2012 SAP AG
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.sap.prd.mobile.ios.mios.xcodeprojreader.treeelements;
21+
22+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.Dict;
23+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.NamedElement;
24+
import com.sap.prd.mobile.ios.mios.xcodeprojreader.ProjectFile;
25+
26+
public abstract class TreeElement extends NamedElement
27+
{
28+
29+
private final static Package treeElementsPackage = TreeElement.class.getPackage();
30+
31+
public TreeElement(ProjectFile projectFile)
32+
{
33+
this(projectFile, projectFile.createDict());
34+
}
35+
36+
public TreeElement(ProjectFile projectFile, Dict dict)
37+
{
38+
super(projectFile, dict);
39+
}
40+
41+
public String getPath()
42+
{
43+
return getDict().getString("path");
44+
}
45+
46+
public String getSourceTree()
47+
{
48+
return getDict().getString("sourceTree");
49+
}
50+
51+
public static TreeElement create(ProjectFile projectFile, Dict dict)
52+
{
53+
final String isa = dict.getString("isa");
54+
try {
55+
final Class<?> clazz = Class.forName(treeElementsPackage.getName() + "." + isa);
56+
return (TreeElement) clazz.getDeclaredConstructor(new Class[] { ProjectFile.class, Dict.class }).newInstance(
57+
projectFile, dict);
58+
}
59+
catch (RuntimeException e) {
60+
throw e;
61+
}
62+
catch (Exception e) {
63+
throw new RuntimeException("Could not instanciate tree element for type (isa) '" + isa + "'.", e);
64+
}
65+
}
66+
}

0 commit comments

Comments
 (0)