Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7942721d8caf4751f92a826246825d9bbd5d6be9 (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
/*******************************************************************************
 * Copyright (c) 2002, 2004 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.wst.ws.internal.explorer.platform.wsdl.fragment;

import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.impl.*;
import org.eclipse.wst.ws.internal.explorer.platform.wsdl.fragment.util.XSDTypeDefinitionUtil;
import org.eclipse.wst.ws.internal.explorer.platform.wsdl.xsd.*;
import org.eclipse.xsd.XSDComplexTypeDefinition;
import org.eclipse.xsd.XSDComplexTypeContent;

public class XSDComplexTypeToFragmentMapper extends XSDToFragmentMapper {
  public XSDComplexTypeToFragmentMapper(XSDToFragmentController controller, WSDLPartsToXSDTypeMapper wsdlToXSDMapper) {
    super(controller, wsdlToXSDMapper);
  }

  public IXSDFragment getFragment(XSDToFragmentConfiguration config, String id, String name) {
    XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition)config.getXSDComponent();
    if (complexType != null && complexType.isMixed())
      return getXSDDefaultFragment(config, id, name);
    XSDComplexTypeContent complexTypeContent = XSDTypeDefinitionUtil.getXSDComplexTypeContent(complexType);
    if (complexTypeContent != null)
      return getXSDComplexFragment(config, id, name);
    else
      return getXSDEmptyFragment(config, id, name);
  }

  private IXSDFragment getXSDComplexFragment(XSDToFragmentConfiguration config, String id, String name) {
    int minOccurs = config.getMinOccurs();
    int maxOccurs = config.getMaxOccurs();
    IXSDComplexFragment frag;
    if (minOccurs == maxOccurs)
      return new XSDComplexFixFragment(id, name, config, getController());
    else
      return new XSDComplexRangeFragment(id, name, config, getController());
  }
}

Back to the top