Package org.eclipse.emf.ecore

Examples of org.eclipse.emf.ecore.EValidator$Descriptor


        listOfPatches = detector.getDescriptors(ColorVQFloatDescriptor.class, bfImg.getSubimage(0, move, bfImg.getWidth(), deltaMove));       
      }
      for(ColorVQFloatDescriptor i : listOfPatches)
      {
        //the descriptor
        Descriptor cvqfd = new ColorVQFloatDescriptor();
        cvqfd.setXmin(i.getXmin());
        cvqfd.setXmax(i.getXmax());
        cvqfd.setYmin(i.getYmin());
        cvqfd.setYmax(i.getYmax());
        cvqfd.setShape(i.getShape());
        float[] d = new float[quantizer.getBinNumber()];
     
        float surf = (i.getXmax() - i.getXmin())*(i.getYmax()-i.getYmin());
        for(int x = i.getXmin(); x < i.getXmax(); ++x)
          for(int y = i.getYmin(); y < i.getYmax(); ++y)
          {
            int[] color = r.getPixel(x, y, (int[])null);
            int index = quantizer.getBin(color);
            if(index >= 0 && index < d.length)
            {
              if(normalize)
                d[index] += 1.0f/surf;
              else
                d[index] += 1.0f;
            }
          }
     
        cvqfd.setD(d);
     
        list.add(cvqfd);
      }
    }
    if(DEBUG)
View Full Code Here


   
    ArrayList<Descriptor> list = new ArrayList<Descriptor>();
   
    while(!line.startsWith("</image"))
    {     
      Descriptor d = null;
     
      //1. head
      String head = line.substring(line.indexOf("<")+1, line.indexOf(">"));
      String[] arguments = head.split(" ");
      Class c = Descriptor.class;
     
      for(String p : arguments)
      {
        if(p.startsWith("<"))
        {
         
        }
        else if(p.startsWith("class"))
        {
          String[] s = p.split("=");
          if(s.length > 1)
          {
            String descriptorClass = s[1].trim().replaceAll("\"", "");
            c = XMLReader.class.getClassLoader().loadClass(descriptorClass);
           
            d = (Descriptor<?>) c.newInstance();
          }
        }
        else if(p.startsWith("xmin"))
        {
          String[] s = p.split("=");
          if(s.length > 1)
          {
            String xmin = s[1].trim().replaceAll("\"", "");
            d.setXmin(Integer.parseInt(xmin));
           
          }
        }
        else if(p.startsWith("xmax"))
        {
          String[] s = p.split("=");
          if(s.length > 1)
          {
            String xmax = s[1].trim().replaceAll("\"", "");
            d.setXmax(Integer.parseInt(xmax));
           
          }
        }
        else if(p.startsWith("ymin"))
        {
          String[] s = p.split("=");
          if(s.length > 1)
          {
            String ymin = s[1].trim().replaceAll("\"", "");
            d.setYmin(Integer.parseInt(ymin));
           
          }
        }
        else if(p.startsWith("ymax"))
        {
          String[] s = p.split("=");
          if(s.length > 1)
          {
            String ymax = s[1].trim().replaceAll("\"", "");
            d.setYmax(Integer.parseInt(ymax));
           
          }
        }
        else if(p.startsWith("shape"))
        {
          String[] s = p.split("=");
          if(s.length > 1)
          {
            String shape = s[1].trim().replaceAll("\"", "");
            d.setShape(shape);
           
          }
        }
      }
     
     
      //2. body
      String body = line.substring(line.indexOf('>')+1, line.lastIndexOf('<')).trim();
      String[] values = body.split(",");
      try {
        d.initD();
        String dClass = d.getD().getClass().toString();
        //double
        if(dClass.equalsIgnoreCase("class [D"))
        {
          double[] v = new double[values.length];
          for(int i = 0 ; i < v.length; i++)
            v[i] = Double.parseDouble(values[i]);
         
          d.setD(v);
        }
        //float
        else if(dClass.equalsIgnoreCase("class [F"))
        {
          float[] v = new float[values.length];
          for(int i = 0 ; i < v.length; i++)
            v[i] = Float.parseFloat(values[i]);
         
          d.setD(v);   
        }
        else
        {
          System.out.println("NOT VALID CLASS");
        }
View Full Code Here

  protected EValidator getRootEValidator(Map<Object, Object> context)
  {
    if (context != null)
    {
      EValidator result = (EValidator)context.get(EValidator.class);
      if (result != null)
      {
        return result;
      }
    }
View Full Code Here

    {
      return true;
    }
    boolean result = true;
    EDataType eDataType = eAttribute.getEAttributeType();
    EValidator rootValidator = getRootEValidator(context);
    Object value = eObject.eGet(eAttribute);
    if (FeatureMapUtil.isFeatureMap(eAttribute))
    {
      @SuppressWarnings("unchecked") Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value;
      EClass eClass = eObject.eClass();
      Map<EStructuralFeature, DiagnosticChain> entryFeatureToDiagnosticChainMap = null;
      for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null); )
      {
        FeatureMap.Entry entry = i.next();
        EStructuralFeature entryFeature = entry.getEStructuralFeature();
        if (entryFeature instanceof EAttribute &&
              ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute)
        {
          EDataType entryType = (EDataType)entryFeature.getEType();
          Object entryValue = entry.getValue();
          boolean entryIsValid = rootValidator.validate(entryType, entryValue, null, context);
          if (!entryIsValid)
          {
            result = false;
            if (diagnostics != null)
            {
              if (entryFeatureToDiagnosticChainMap == null)
              {
                entryFeatureToDiagnosticChainMap = new HashMap<EStructuralFeature, DiagnosticChain>();
              }
              DiagnosticChain entryFeatureDiagnostic = entryFeatureToDiagnosticChainMap.get(entryFeature);
              if (entryFeatureDiagnostic == null)
              {
                entryFeatureDiagnostic = createBadDataValueDiagnostic(eObject, (EAttribute)entryFeature, diagnostics, context);
                entryFeatureToDiagnosticChainMap.put(entryFeature, entryFeatureDiagnostic);
              }
              rootValidator.validate(entryType, entryValue, entryFeatureDiagnostic, context);
            }
          }
        }
      }
    }
    else if (eAttribute.isMany())
    {
      for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && result; )
      {
        result &= rootValidator.validate(eDataType, i.next(), null, context);
      }

      if (!result && diagnostics != null)
      {
        DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
        for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext(); )
        {
          rootValidator.validate(eDataType, i.next(), diagnostic, context);
        }
      }
    }
    else if (value != null)
    {
      result = rootValidator.validate(eDataType, value, null, context);
      if (!result && diagnostics != null)
      {
        DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
        rootValidator.validate(eDataType, value, diagnostic, context);
      }
    }

    return result;
  }
View Full Code Here

        }
      }
     
      if (builtinType != null)
      {
        EValidator rootValidator = getRootEValidator(context);
        result &= rootValidator.validate(builtinType, value, diagnostics, context);
      }

      return result;
    }
View Full Code Here

      {
        result &= validateSchemaConstraints(eDataType, value, diagnostics, context);

        if (itemType != null)
        {
          EValidator rootValidator = getRootEValidator(context);
          for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && (result || diagnostics != null);)
          {
            result &= rootValidator.validate(itemType, i.next(), diagnostics, context);
          }
          return result;
        }
        else if (!memberTypes.isEmpty())
        {
          EValidator rootValidator = getRootEValidator(context);

          for (EDataType memberType : memberTypes)
          {
            if (rootValidator.validate(memberType, value, null, context))
            {
              return true;
            }
          }
          for (EDataType memberType : memberTypes)
          {
            if (memberType.isInstance(value))
            {
              return rootValidator.validate(memberType, value, diagnostics, context);
            }
          }
          return false;
        }
        else
View Full Code Here

  protected EValidator getRootEValidator(Map<Object, Object> context)
  {
    if (context != null)
    {
      EValidator result = (EValidator)context.get(EValidator.class);
      if (result != null)
      {
        return result;
      }
    }
View Full Code Here

    {
      return true;
    }
    boolean result = true;
    EDataType eDataType = eAttribute.getEAttributeType();
    EValidator rootValidator = getRootEValidator(context);
    Object value = eObject.eGet(eAttribute);
    if (FeatureMapUtil.isFeatureMap(eAttribute))
    {
      @SuppressWarnings("unchecked") Collection<FeatureMap.Entry> featureMap = (Collection<FeatureMap.Entry>)value;
      EClass eClass = eObject.eClass();
      Map<EStructuralFeature, DiagnosticChain> entryFeatureToDiagnosticChainMap = null;
      for (Iterator<FeatureMap.Entry> i = featureMap.iterator(); i.hasNext() && (result || diagnostics != null); )
      {
        FeatureMap.Entry entry = i.next();
        EStructuralFeature entryFeature = entry.getEStructuralFeature();
        if (entryFeature instanceof EAttribute &&
              ExtendedMetaData.INSTANCE.getAffiliation(eClass, entryFeature) == eAttribute)
        {
          EDataType entryType = (EDataType)entryFeature.getEType();
          Object entryValue = entry.getValue();
          boolean entryIsValid = rootValidator.validate(entryType, entryValue, null, context);
          if (!entryIsValid)
          {
            result = false;
            if (diagnostics != null)
            {
              if (entryFeatureToDiagnosticChainMap == null)
              {
                entryFeatureToDiagnosticChainMap = new HashMap<EStructuralFeature, DiagnosticChain>();
              }
              DiagnosticChain entryFeatureDiagnostic = entryFeatureToDiagnosticChainMap.get(entryFeature);
              if (entryFeatureDiagnostic == null)
              {
                entryFeatureDiagnostic = createBadDataValueDiagnostic(eObject, (EAttribute)entryFeature, diagnostics, context);
                entryFeatureToDiagnosticChainMap.put(entryFeature, entryFeatureDiagnostic);
              }
              rootValidator.validate(entryType, entryValue, entryFeatureDiagnostic, context);
            }
          }
        }
      }
    }
    else if (eAttribute.isMany())
    {
      for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext() && result; )
      {
        result &= rootValidator.validate(eDataType, i.next(), null, context);
      }

      if (!result && diagnostics != null)
      {
        DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
        for (Iterator<?> i = ((List<?>)value).iterator(); i.hasNext(); )
        {
          rootValidator.validate(eDataType, i.next(), diagnostic, context);
        }
      }
    }
    else if (value != null)
    {
      result = rootValidator.validate(eDataType, value, null, context);
      if (!result && diagnostics != null)
      {
        DiagnosticChain diagnostic = createBadDataValueDiagnostic(eObject, eAttribute, diagnostics, context);
        rootValidator.validate(eDataType, value, diagnostic, context);
      }
    }

    return result;
  }
View Full Code Here

        }
      }
     
      if (builtinType != null)
      {
        EValidator rootValidator = getRootEValidator(context);
        result &= rootValidator.validate(builtinType, value, diagnostics, context);
      }

      return result;
    }
View Full Code Here

      {
        result &= validateSchemaConstraints(eDataType, value, diagnostics, context);

        if (itemType != null)
        {
          EValidator rootValidator = getRootEValidator(context);
          for (Iterator< ? > i = ((List< ? >)value).iterator(); i.hasNext() && (result || diagnostics != null);)
          {
            result &= rootValidator.validate(itemType, i.next(), diagnostics, context);
          }
          return result;
        }
        else if (!memberTypes.isEmpty())
        {
          EValidator rootValidator = getRootEValidator(context);

          for (EDataType memberType : memberTypes)
          {
            if (rootValidator.validate(memberType, value, null, context))
            {
              return true;
            }
          }
          for (EDataType memberType : memberTypes)
          {
            if (memberType.isInstance(value))
            {
              return rootValidator.validate(memberType, value, diagnostics, context);
            }
          }
          return false;
        }
        else
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.EValidator$Descriptor

Copyright © 2018 www.massapicom. 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.