Example #1
0
  private UserArrayType decodeUserArrayType(
      org.w3c.dom.Element xmlElement, java.util.Map<Integer, AbstractDeclaration> map) {
    org.w3c.dom.Element xmlLeafType =
        edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(xmlElement, "leafType");
    org.w3c.dom.Element xmlDimensionCount =
        edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(
            xmlElement, "dimensionCount");
    org.w3c.dom.Element xmlLeafTypeNode =
        edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(xmlLeafType, "node");

    org.w3c.dom.Node xmlLeafTypeFirstChild = xmlLeafType.getFirstChild();
    if (xmlLeafTypeFirstChild instanceof org.w3c.dom.Element) {
      org.w3c.dom.Element xmlLeafTypeFirstChildElement =
          (org.w3c.dom.Element) xmlLeafTypeFirstChild;
      if (xmlLeafTypeFirstChildElement.hasAttribute(CodecConstants.UNIQUE_KEY_ATTRIBUTE)) {
        int arrayTypeUniqueKey = getUniqueKey(xmlElement);
        int leafTypeUniqueKey = getUniqueKey(xmlLeafTypeFirstChildElement);
        EPIC_HACK_mapArrayTypeKeyToLeafTypeKey.put(arrayTypeUniqueKey, leafTypeUniqueKey);
      }
    }

    NamedUserType leafType = (NamedUserType) decode(xmlLeafTypeNode, map);
    int dimensionCount = Integer.parseInt(xmlDimensionCount.getTextContent());
    return UserArrayType.getInstance(leafType, dimensionCount);
  }
Example #2
0
 private ClassReflectionProxy[] decodeParameters(org.w3c.dom.Element xmlElement) {
   org.w3c.dom.Element xmlParameters =
       edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(
           xmlElement, "parameters");
   java.util.List<org.w3c.dom.Element> xmlTypes =
       edu.cmu.cs.dennisc.xml.XMLUtilities.getChildElementsByTagName(xmlParameters, "type");
   ClassReflectionProxy[] rv = new ClassReflectionProxy[xmlTypes.size()];
   for (int i = 0; i < rv.length; i++) {
     rv[i] = createClassReflectionProxy(xmlTypes.get(i).getAttribute("name"));
   }
   return rv;
 }
Example #3
0
 private FieldReflectionProxy decodeField(org.w3c.dom.Element xmlParent, String nodeName) {
   org.w3c.dom.Element xmlField =
       edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(xmlParent, nodeName);
   ClassReflectionProxy declaringCls = decodeDeclaringClass(xmlField);
   String name = xmlField.getAttribute("name");
   return new FieldReflectionProxy(declaringCls, name);
 }
Example #4
0
 private ConstructorReflectionProxy decodeConstructor(
     org.w3c.dom.Element xmlParent, String nodeName) {
   org.w3c.dom.Element xmlConstructor =
       edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(xmlParent, nodeName);
   ClassReflectionProxy declaringCls = decodeDeclaringClass(xmlConstructor);
   ClassReflectionProxy[] parameterClses = decodeParameters(xmlConstructor);
   boolean isVarArgs = Boolean.parseBoolean(xmlConstructor.getAttribute("isVarArgs"));
   return new ConstructorReflectionProxy(declaringCls, parameterClses, isVarArgs);
 }
Example #5
0
 private AnonymousUserConstructor decodeAnonymousConstructor(
     org.w3c.dom.Element xmlElement, java.util.Map<Integer, AbstractDeclaration> map) {
   org.w3c.dom.Element xmlLeafType =
       edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(
           xmlElement, "anonymousType");
   org.w3c.dom.Element xmlLeafTypeNode = (org.w3c.dom.Element) xmlLeafType.getChildNodes().item(0);
   AnonymousUserType anonymousType = (AnonymousUserType) decode(xmlLeafTypeNode, map);
   return AnonymousUserConstructor.get(anonymousType);
 }
  public edu.cmu.cs.dennisc.java.util.zip.DataSource getOriginalProgramTypeDataSource() {
    java.io.File file = edu.cmu.cs.dennisc.java.net.UriUtilities.getFile(getUri());
    org.lgna.project.Project project = getProject();
    if (file != null) {
      java.util.zip.ZipFile zipFile;
      byte[] buffer = null;
      try {
        zipFile = new java.util.zip.ZipFile(file);
        java.io.InputStream typeStream =
            zipFile.getInputStream(
                new java.util.zip.ZipEntry(
                    org.lgna.project.io.IoUtilities.ORIGINAL_PROGRAM_TYPE_ENTRY_NAME));

        if (typeStream != null) {
          buffer = new byte[typeStream.available()];
          org.apache.axis.utils.IOUtils.readFully(typeStream, buffer);
        } else {
          java.io.ByteArrayOutputStream os = new java.io.ByteArrayOutputStream();
          edu.cmu.cs.dennisc.xml.XMLUtilities.write(project.getProgramType().encode(), os);
          buffer = os.toByteArray();
        }
        zipFile.close();
      } catch (IOException e) {
        e.printStackTrace();
      }

      if (buffer != null) {
        final byte[] originalType = buffer;
        return new edu.cmu.cs.dennisc.java.util.zip.DataSource() {
          @Override
          public String getName() {
            return org.lgna.project.io.IoUtilities.ORIGINAL_PROGRAM_TYPE_ENTRY_NAME;
          }

          @Override
          public void write(java.io.OutputStream os) throws IOException {
            os.write(originalType);
          }
        };
      }
    }
    return null;
  }
Example #7
0
  private MethodReflectionProxy decodeMethod(org.w3c.dom.Element xmlParent, String nodeName) {
    org.w3c.dom.Element xmlMethod =
        edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(xmlParent, nodeName);
    ClassReflectionProxy declaringCls = decodeDeclaringClass(xmlMethod);
    String name = xmlMethod.getAttribute("name");

    String potentialReplacement = Decoder.intraClassMethodMap.get(declaringCls, name);
    if (potentialReplacement != null) {
      name = potentialReplacement;
    } else {
      ClassReflectionProxyAndMethodName classReflectionProxyAndMethodName =
          Decoder.betweenClassesMethodMap.get(declaringCls, name);
      if (classReflectionProxyAndMethodName != null) {
        declaringCls = classReflectionProxyAndMethodName.getClassReflectionProxy();
        name = classReflectionProxyAndMethodName.getName();
      }
    }

    //		name = filterMethodNameIfNecessary( declaringCls, name );
    ClassReflectionProxy[] parameterClses = decodeParameters(xmlMethod);
    boolean isVarArgs = Boolean.parseBoolean(xmlMethod.getAttribute("isVarArgs"));
    return new MethodReflectionProxy(declaringCls, name, parameterClses, isVarArgs);
  }
Example #8
0
 private ClassReflectionProxy decodeType(org.w3c.dom.Element xmlElement, String nodeName) {
   org.w3c.dom.Element xmlClass =
       edu.cmu.cs.dennisc.xml.XMLUtilities.getSingleChildElementByTagName(xmlElement, nodeName);
   String clsName = xmlClass.getAttribute("name");
   return createClassReflectionProxy(clsName);
 }