Skip to main content
summaryrefslogtreecommitdiffstats
blob: ece239b41373e9ddf685d4808bb406f6e87511e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*******************************************************************************
 * Copyright (c) 2001, 2005 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 * IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jst.j2ee.client.internal.impl;



import org.eclipse.emf.common.util.URI;
import org.eclipse.jst.j2ee.client.ApplicationClient;
import org.eclipse.jst.j2ee.client.ApplicationClientResource;
import org.eclipse.jst.j2ee.common.internal.impl.XMLResourceImpl;
import org.eclipse.jst.j2ee.internal.J2EEConstants;
import org.eclipse.jst.j2ee.internal.model.translator.client.ApplicationClientTranslator;
import org.eclipse.wst.common.internal.emf.resource.Renderer;
import org.eclipse.wst.common.internal.emf.resource.Translator;

public class ApplicationClientResourceImpl extends XMLResourceImpl implements ApplicationClientResource {
	/**
	 * Constructor for ApplicationClientResourceImpl.
	 * @param uri
	 * @param aRenderer
	 */
	public ApplicationClientResourceImpl(URI uri, Renderer aRenderer) {
		super(uri, aRenderer);
	}

	/**
	 * Constructor for ApplicationClientResourceImpl.
	 * @param aRenderer
	 */
	public ApplicationClientResourceImpl(Renderer aRenderer) {
		super(aRenderer);
	}

	/**
	 * Return the first element in the EList.
	 */
	public ApplicationClient getApplicationClient() {
		return (ApplicationClient) getRootObject();
	}

	
	public int getType() {
		return APP_CLIENT_TYPE;
	}


	/* (non-Javadoc)
	 * @see com.ibm.etools.j2eexml.XMLResourceImpl#getJ2EE_1_2_SystemID()
	 */
	public String getJ2EE_1_2_SystemID() {
		return J2EEConstants.APP_CLIENT_SYSTEMID_1_2;
	}
	
	public String getJ2EE_Alt_1_2_SystemID() {
		return J2EEConstants.APP_CLIENT_ALT_SYSTEMID_1_2;
	}

	/* (non-Javadoc)
	 * @see com.ibm.etools.j2eexml.XMLResourceImpl#getJ2EE_1_3_SystemID()
	 */
	public String getJ2EE_1_3_SystemID() {
		return J2EEConstants.APP_CLIENT_SYSTEMID_1_3;
	}
	
	public String getJ2EE_Alt_1_3_SystemID() {
		return J2EEConstants.APP_CLIENT_ALT_SYSTEMID_1_3;
	}
	
	/* (non-Javadoc)
	 * @see com.ibm.etools.j2eexml.XMLResourceImpl#getJ2EE_1_2_PublicID()
	 */
	public String getJ2EE_1_2_PublicID() {
		return J2EEConstants.APP_CLIENT_PUBLICID_1_2;
	}
	/* (non-Javadoc)
	 * @see com.ibm.etools.j2eexml.XMLResourceImpl#getJ2EE_1_3_PublicID()
	 */
	public String getJ2EE_1_3_PublicID() {
		return J2EEConstants.APP_CLIENT_PUBLICID_1_3;
	}


	public String getDoctype() {
		switch (getJ2EEVersionID()) {
			case (J2EE_1_2_ID) :
			case (J2EE_1_3_ID) :	
				return J2EEConstants.APP_CLIENT_DOCTYPE;
			default :
				return null;
		}
	}
	
	/**
	 * @see com.ibm.etools.emf2xml.TranslatorResource#getRootTranslator()
	 */
	public Translator getRootTranslator() {
		return ApplicationClientTranslator.INSTANCE;
	}

	/* App client version is always the same as the J2EE version
	 */
	public int getJ2EEVersionID() {
		return getModuleVersionID();
	}
	/* 
	 * This directly sets the module version id
	 */
	public void setModuleVersionID(int id) {
		super.setVersionID(id);
		switch (id) {
				case (J2EE_1_4_ID) :
					super.setDoctypeValues(null, null);
					break;
				case (J2EE_1_3_ID) :
					super.setDoctypeValues(getJ2EE_1_3_PublicID(), getJ2EE_1_3_SystemID());
					break;
				case (J2EE_1_2_ID) :
					super.setDoctypeValues(getJ2EE_1_2_PublicID(), getJ2EE_1_2_SystemID());
			}
		syncVersionOfRootObject();
	}
		/*
		 * Based on the J2EE version, this will set the module version(Same as J2EE Version for App client)
		 */
		public void setJ2EEVersionID(int id) {
		primSetVersionID(id);
		switch (id) {
					case (J2EE_1_4_ID) :
						primSetDoctypeValues(null, null);
						break;
					case (J2EE_1_3_ID) :
						primSetDoctypeValues(getJ2EE_1_3_PublicID(), getJ2EE_1_3_SystemID());
						break;
					case (J2EE_1_2_ID) :
						primSetDoctypeValues(getJ2EE_1_2_PublicID(), getJ2EE_1_2_SystemID());
				}
			syncVersionOfRootObject();
		}
	/* (non-Javadoc)
	 * @see org.eclipse.jst.j2ee.internal.common.impl.XMLResourceImpl#syncVersionOfRootObject()
	 */
	protected void syncVersionOfRootObject() {
		ApplicationClient clt = getApplicationClient();
		if (clt == null)
			return;
	
		String version = clt.getVersion();
		String newVersion = getModuleVersionString();
		if (!newVersion.equals(version))
			clt.setVersion(newVersion);
	}


}

Back to the top