Examples of ResourceSet


Examples of org.eclipse.emf.ecore.resource.ResourceSet

    return (DataObject)EcoreUtil.create((EClass)type);
  }
 
  public static ResourceSet createResourceSet()
  {
    ResourceSet result = new ResourceSetImpl();
    configureResourceSet(result);
    return result;
  }
View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

 
  //TODO clean up the options thing
  protected XMLDocumentImpl(ExtendedMetaData extendedMetaData, Object options)
  {
    this.extendedMetaData = extendedMetaData;
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
   
    if (options instanceof Map)
    {
      Class resourceFactoryClass = (Class)((Map)options).get("GENERATED_LOADER");
      if (resourceFactoryClass != null)
      {
        try
        {
          Object resourceFactory = resourceFactoryClass.newInstance();
          resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("*", resourceFactory);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    }
 
    resource = (XMLResource)resourceSet.createResource(URI.createURI("http:///temp.xml"));
   
    XMLOptions xmlOptions = new XMLOptionsImpl();
    xmlOptions.setProcessAnyXML(true);
    resource.getDefaultLoadOptions().put(XMLResource.OPTION_XML_OPTIONS, xmlOptions);

View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

    }
  }
 
  public static void generatePackages(Collection packageList, String packageURI, String shortName, String targetDirectory, String javaPackage, String prefix, int genOptions)
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    List usedGenPackages = new ArrayList();
    GenModel genModel = null;
    for (Iterator iter = packageList.iterator(); iter.hasNext();)
    {
      EPackage currentEPackage = (EPackage)iter.next();
View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

  /**
   * @deprecated
   */
  public static String getSchemaNamespace(String xsdFileName)
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    File inputFile = new File(xsdFileName).getAbsoluteFile();
    Resource model = resourceSet.getResource(URI.createURI(inputFile.toURI().toString()), true);
    XSDSchema schema = (XSDSchema)model.getContents().get(0);
    return schema.getTargetNamespace();
  }
View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

  public static void generateFromEPackage(EPackage ePackage, String targetDirectory, String basePackage, String prefix, int genOptions)
  {
    GenModel genModel = ecore2GenModel(ePackage, basePackage, prefix, genOptions);

    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    URI ecoreURI = URI.createURI("file:///temp.ecore");
    URI genModelURI = ecoreURI.trimFileExtension().appendFileExtension("genmodel");

    Resource ecoreResource = resourceSet.createResource(ecoreURI);
    ecoreResource.getContents().add(ePackage);

    Resource genModelResource = resourceSet.createResource(genModelURI);
    genModelResource.getContents().add(genModel);

    generateFromGenModel(genModel, targetDirectory, genOptions);
  }
View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

   * <!-- end-user-doc -->
   * @generated
   */
  public void setResourceSetGen(ResourceSet newResourceSet)
  {
    ResourceSet oldResourceSet = resourceSet;
    resourceSet = newResourceSet;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SDOPackage.DATA_GRAPH__RESOURCE_SET, oldResourceSet, resourceSet));
  }
View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

    {
      int length = objectInput.readInt();
      byte [] bytes = new byte [length];
      objectInput.readFully(bytes);

      ResourceSet resourceSet = createResourceSet();
      Resource resource = resourceSet.createResource(URI.createURI("all.datagraph"));
      resource.load(new ByteArrayInputStream(bytes), null);
      eDataGraph = (DataGraphImpl)resource.getContents().get(0);
    }
View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

  protected List /*Type*/define(InputSource inputSource, String schemaLocation)
  {
    try
    {
      ResourceSet resourceSet = DataObjectUtil.createResourceSet();
      Resource model = resourceSet.createResource(URI.createURI(schemaLocation != null ? schemaLocation : "null.xsd"));
      ((XSDResourceImpl)model).load(inputSource, null);
     
      List newTypes = new ArrayList();
      for (Iterator schemaIter = model.getContents().iterator(); schemaIter.hasNext(); )
      {
View Full Code Here

Examples of org.eclipse.emf.ecore.resource.ResourceSet

    }
  }
 
  public static String getSchemaNamespace(String xsdFileName)
  {
    ResourceSet resourceSet = DataObjectUtil.createResourceSet();
    File inputFile = new File(xsdFileName).getAbsoluteFile();
    Resource model = resourceSet.getResource(URI.createURI(inputFile.toURI().toString()), true);
    XSDSchema schema = (XSDSchema)model.getContents().get(0);
    return schema.getTargetNamespace();
  }
View Full Code Here

Examples of org.thechiselgroup.choosel.core.client.resources.ResourceSet

    public ResourceSet createResources(StringTable table) throws ParseException {
        assert table != null;

        String uriType = uriHeaderProvider.nextLabel();

        ResourceSet resources = new DefaultResourceSet();
        resources.setLabel("import"); // TODO changeable, inc number

        if (table.getRowCount() == 0) {
            return resources;
        }

        // use first row to determine types
        DataType[] columnTypes = new DataType[table.getColumnCount()];
        for (int column = 0; column < table.getColumnCount(); column++) {
            String stringValue = table.getValue(0, column);

            if (NUMBER_DETECTION_REGEX.test(stringValue)) {
                columnTypes[column] = DataType.NUMBER;
            } else if (DATE_FORMAT_1_REGEX.test(stringValue)) {
                columnTypes[column] = DataType.DATE;
            } else if (DATE_FORMAT_2_REGEX.test(stringValue)) {
                columnTypes[column] = DataType.DATE;
            } else if (LOCATION_DETECTION_REGEX.test(stringValue)) {
                columnTypes[column] = DataType.LOCATION;
            } else {
                columnTypes[column] = DataType.TEXT;
            }
        }

        for (int row = 0; row < table.getRowCount(); row++) {
            String uri = uriType + ":" + row;
            Resource resource = new Resource(uri);

            for (int column = 0; column < table.getColumnCount(); column++) {
                String stringValue = table.getValue(row, column);

                /*
                 * TODO should not be parsed at this point - change once setting
                 * property types possible
                 */
                Serializable value;

                switch (columnTypes[column]) {
                case NUMBER:
                    if (!NUMBER_DETECTION_REGEX.test(stringValue)) {
                        throw new ParseException("Invalid number", stringValue,
                                row + 1);
                    }
                    value = new Double(stringValue);
                    break;
                case DATE:
                    if (DATE_FORMAT_1_REGEX.test(stringValue)) {
                        value = parseDate1(stringValue);
                    } else if (DATE_FORMAT_2_REGEX.test(stringValue)) {
                        value = parseDate2(stringValue);
                    } else {
                        throw new ParseException("Invalid date", stringValue,
                                row + 1);
                    }
                    break;
                case LOCATION:
                    if (!LOCATION_DETECTION_REGEX.test(stringValue)) {
                        throw new ParseException("Invalid location",
                                stringValue, row + 1);
                    }

                    Resource locationResource = new Resource();
                    String[] split = stringValue.split("\\/");
                    locationResource.putValue(ResourceSetUtils.LATITUDE,
                            Double.parseDouble(split[0]));
                    locationResource.putValue(ResourceSetUtils.LONGITUDE,
                            Double.parseDouble(split[1]));
                    value = locationResource;
                    break;
                default:
                    value = stringValue;
                    break;
                }

                resource.putValue(table.getColumnName(column), value);
            }

            resources.add(resource);
        }

        return resources;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.