Java 类org.jdom.DataConversionException 实例源码

项目:mars-sim    文件:BuildingConfig.java   
/**
 * Gets the relative location in the building of a parking location.
 * @param buildingType the type of the building.
 * @param parkingIndex the parking location index.
 * @return Point object containing the relative X & Y position from the building center.
 */
public Point2D.Double getParkingLocation(String buildingType, int parkingIndex) {
    Element buildingElement = getBuildingElement(buildingType);
       Element functionsElement = buildingElement.getChild(FUNCTIONS);
       Element groundVehicleMaintenanceElement = functionsElement.getChild(GROUND_VEHICLE_MAINTENANCE);
       List<?> parkingLocations = groundVehicleMaintenanceElement.getChildren(PARKING_LOCATION);
       if ((parkingIndex >= 0) && (parkingIndex < parkingLocations.size())) {
           Element parkingLocation = (Element) parkingLocations.get(parkingIndex);
           try {
               Point2D.Double point = new Point2D.Double();
               double xLocation = parkingLocation.getAttribute(X_LOCATION).getDoubleValue();
               double yLocation = parkingLocation.getAttribute(Y_LOCATION).getDoubleValue();
               point.setLocation(xLocation, yLocation);
               return point;
           }
           catch (DataConversionException e) {
               throw new IllegalStateException(e);
           }
       }
       else {
           return null;
       }
}
项目:cn1    文件:ReferenceCounting.java   
/**
 * The entry point to this class. This function takes a method element and
 * processes it, adding instructions to release and retain objects as
 * needed. For the command set that it adds, see the InstructionProcessor
 * class.
 */
@SuppressWarnings("unchecked")
public void process(Element method) throws DataConversionException, ReferenceCountingException {

    Attribute isAbstract = method.getAttribute("isAbstract");
    Attribute isNative = method.getAttribute("isNative");
    // abstract and native methods do not require processing
    if (isAbstract != null && isAbstract.getBooleanValue()) {
        return;
    }

    if (isNative != null && isNative.getBooleanValue()) {
        return;
    }

    Element codeElement = method.getChild("code", dex);

    int numReg = codeElement.getAttribute("register-size").getIntValue();
    processRecStart(numReg, (List<Element>) codeElement.getChildren(), codeElement);
}
项目:cn1    文件:ReferenceCounting.java   
/**
 * This adds any labels it finds to our labels map. It also populates our
 * previous and next element hashes.
 */
private void addToNextPrevElement(List<Element> toProcess) throws DataConversionException {
    Element prev = null;
    for (int k = 0; k < toProcess.size(); k++) {
        Element cur = toProcess.get(k);

        if (cur.getName().equals("label")) {
            labels.put(cur.getAttribute("id").getIntValue(), cur);
        }

        if (prev != null) {
            nextElement.put(prev, cur);
            prevElement.put(cur, prev);
        }
        prev = cur;
    }
}
项目:cn1    文件:ReferenceCounting.java   
/**
 * This function creates a InstructionUseInfo based on the current element
 * TODO: if anyone really cares this can be made faster by not using
 * reflection.
 */
private static InstructionUseInfo processElement(Element element)
        throws DataConversionException {
    InstructionUseInfo use = new InstructionUseInfo(element);
    // If we find the instruction using the generic handler, return
    // immediately.
    if (InstructionProcessor.processGeneric(element, use)) {
        return use;
    } else {
        // Otherwise, we need to hit the correct processor function:
        String todo = "process_" + element.getName().replace("-", "_");
        Method method;
        try {
            method = InstructionProcessor.class.getMethod(todo, Element.class,
                    InstructionUseInfo.class);
            method.invoke(null, element, use);
        } catch (Exception ex) {
            throw new DataConversionException(ex.getMessage(), "When attempting to: " + todo);
        }
    }
    return use;
}
项目:cn1    文件:InstructionProcessor.java   
static void getMoveResult(Element funcCallElement, InstructionUseInfo i)
        throws DataConversionException {
    String returnType = funcCallElement.getChild("parameters", dex).getChild("return", dex)
            .getAttribute("type").getValue();
    boolean returnsVoid = returnType.equals("void");

    Element pHolder = funcCallElement.getChild("move-result", dex);
    if (pHolder != null) {
        i.checkUsage(pHolder.getAttribute("vx"), pHolder.getAttribute("vx-type"));
        i.isWrite = true;
    } else {
        if (!returnsVoid && !nonObjTypes.matcher(returnType).matches()) {
            // if the result is an object and it is not used, we must
            // free rTmp. Recall that xmlvm2objc.xsl sticks unused results
            // into rTmp.
            i.freeTmpAfter = true;

        }
        i.isWrite = false;
    }
}
项目:cn1    文件:InstructionProcessor.java   
@SuppressWarnings("unchecked")
static public void process_iput_object(Element element, InstructionUseInfo i)
        throws DataConversionException {
    // need to release before we overwrite

    i.requiresRetain.orEq(getDestReg(element, "vx").and(i.usesAsObj()));
    if (!i.requiresRetain.isEmpty()) {

        Element toAdd = new Element(cmd_i_release, vm);
        for (Attribute a : (List<Attribute>) i.Instruction.getAttributes()) {
            toAdd.setAttribute(a.getName(), a.getValue(), a.getNamespace());
        }

        i.putRelease = toAdd;
    }
    i.isWrite = false;
}
项目:cn1    文件:InstructionProcessor.java   
@SuppressWarnings("unchecked")
static public void process_sput_object(Element element, InstructionUseInfo i)
        throws DataConversionException {

    i.requiresRetain.orEq(getDestReg(element, "vx").and(i.usesAsObj()));
    if (!i.requiresRetain.isEmpty()) {
        // need to release before we overwrite
        Element toAdd = new Element(cmd_s_release, vm);
        for (Attribute a : (List<Attribute>) i.Instruction.getAttributes()) {
            toAdd.setAttribute(a.getName(), a.getValue(), a.getNamespace());
        }

        i.putRelease = toAdd;
    }
    i.isWrite = false;
}
项目:cn1    文件:InstructionUseInfo.java   
/**
 * Returns the registers which this instruction writes objects into
 */
public RegisterSet writesObj() throws DataConversionException {
    if (isWrite) {
        for (Attribute key : typeIsObj.keySet()) {
            for (String s : possibleWrites) {
                if (key.getName().equals(s)) {
                    if (typeIsObj.get(key)) {
                        return RegisterSet.from(key.getIntValue());
                    }
                }
            }
        }
    }
    return RegisterSet.none();

}
项目:cn1    文件:InstructionUseInfo.java   
/**
 * Complete dump of all registers used by this instruction
 */
public String toString() {

    StringBuilder toRet = new StringBuilder();
    try {
        toRet.append(Instruction.getName());
        if (isWrite) {
            if (!writesNonObj().isEmpty()) {
                toRet.append(" Wi:" + writesNonObj());
            } else {
                toRet.append(" Wo:" + writesObj());
            }
        }
        if (!usesAsNonObj().isEmpty()) {
            toRet.append(" Ri:" + usesAsNonObj());
        }
        if (!usesAsObj().isEmpty()) {
            toRet.append(" Ro:" + usesAsObj());
        }
    } catch (DataConversionException ex) {
        toRet.append(ex.getMessage());
    }
    return toRet.toString();
}
项目:yada    文件:LanziusServer.java   
private boolean validateSection(Element sectionElement, String expectedChildName, int attributes) {

        // Check that section exists
        if(sectionElement==null) return false;

        // Go through children
        Iterator iter = sectionElement.getChildren().iterator();
        while(iter.hasNext()) {
            Element e = (Element)iter.next();
            // Check that child is expected
            if(!e.getName().equals(expectedChildName)) return false;
            // Check id attribute for existence, isnumber and range (1-4095)
            if((attributes|ATTR_ID)!=0) {
                Attribute a = e.getAttribute("id");
                if(a==null) return false;
                try {
                    int value = a.getIntValue();
                    if(value<=0||value>=(1<<ID_BITSHIFT)) return false;
                } catch(DataConversionException ex) {
                    return false;
                }
            }
        }
        return true;
    }
项目:redis-game-transaction    文件:RGTConfigService.java   
public JedisPoolConfig initRediPoolConfig() throws DataConversionException {
    Element element = JdomUtils.getRootElemet(FileUtil.getConfigURL(GlobalConstants.RedisConfigFile.REDIS_POOL_CONIFG).getFile());
    JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();
    int maxIdle = element.getAttribute("maxIdle").getIntValue();
    boolean testWhileIdle = element.getAttribute("testWhileIdle").getBooleanValue();
    int timeBetweenEvictionRunsMillis = element.getAttribute("timeBetweenEvictionRunsMillis").getIntValue();
    int numTestsPerEvictionRun = element.getAttribute("numTestsPerEvictionRun").getIntValue();
    int minEvictableIdleTimeMillis = element.getAttribute("minEvictableIdleTimeMillis").getIntValue();
    jedisPoolConfig.setTestWhileIdle(testWhileIdle);
    jedisPoolConfig.setMaxIdle(maxIdle);
    jedisPoolConfig.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    jedisPoolConfig.setNumTestsPerEvictionRun(numTestsPerEvictionRun);
    jedisPoolConfig.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    return jedisPoolConfig;
}
项目:redis-game-transaction    文件:RGTConfigService.java   
public JedisPool initRedis(JedisPoolConfig jedisPoolConfig) throws DataConversionException {
    Element element = JdomUtils.getRootElemet(FileUtil.getConfigURL(GlobalConstants.RedisConfigFile.REDIS).getFile());
    String host = element.getAttribute("host").getValue();
    int port = element.getAttribute("port").getIntValue();
    boolean hasPassword = element.getAttribute("password") != null;
    int database = element.getAttribute("database").getIntValue();
    JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port);
    if (hasPassword) {
        int timeout = element.getAttribute("timeout").getIntValue();
        String password = element.getAttribute("password").getValue();
        jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, password, database);
    }
    return jedisPool;
}
项目:redis-game-transaction    文件:RedisServiceTest.java   
public static void main(String[] args) throws DataConversionException {
    RGTConfigService RGTConfigService = new RGTConfigService();
    RGTRedisService RGTRedisService = new RGTRedisService();
    RGTRedisService.setJedisPool(RGTConfigService.initRedis(RGTConfigService.initRediPoolConfig()));

    String testKey = "ketest100";
    RGTRedisService.setString(testKey, "100");
    String number = RGTRedisService.getString(testKey);
    System.out.println(number);
}
项目:intellij-ce-playground    文件:Configuration.java   
public void readExternal(Element element) {
  name = element.getAttributeValue(NAME_ATTRIBUTE_NAME);
  final Attribute attribute = element.getAttribute(CREATED_ATTRIBUTE_NAME);
  if (attribute != null) {
    try {
      created = attribute.getLongValue();
    }
    catch (DataConversionException ignore) {}
  }
}
项目:intellij-ce-playground    文件:ProjectLevelVcsManagerImpl.java   
@Override
public void readExternal(Element element) throws InvalidDataException {
  mySerialization.readExternalUtil(element, myOptionsAndConfirmations);
  final Attribute attribute = element.getAttribute(SETTINGS_EDITED_MANUALLY);
  if (attribute != null) {
    try {
      myHaveLegacyVcsConfiguration = attribute.getBooleanValue();
    }
    catch (DataConversionException e) {
      //
    }
  }
}
项目:TCSlackNotifierPlugin    文件:SlackProjectSettings.java   
public void readFrom(Element element) {
    Element channelElement = element.getChild(ELEMENT_CHANNEL);
    Element logoElement = element.getChild(ELEMENT_LOGO_URL);
    Attribute enabledAttr = element.getAttribute(ATTR_ENABLED);

    if( enabledAttr != null )
    {
        try {
            enabled = enabledAttr.getBooleanValue() ;
        } catch (DataConversionException e) {
            enabled = true ;
        }
    }
    else
    {
        enabled = true ;
    }

    if( channelElement != null ) {
        this.channel = channelElement.getText();
    }

    if( logoElement != null )
    {
        this.logoUrl = logoElement.getText();
    }
}
项目:cn1    文件:ReferenceCounting.java   
/**
 * Set the expected frees that we must do before any optimizations have
 * removed them.
 */
private void setWillFree(Map<Element, InstructionActions> beenTo)
        throws ReferenceCountingException, DataConversionException {
    {
        for (Map.Entry<Element, InstructionActions> e : beenTo.entrySet()) {
            RegisterSet objectRegs = e.getValue().getObjectRegs();

            if (!e.getValue().getConflict().isEmpty()) {
                throw new ReferenceCountingException(
                        "Ambigious register contents possible: Conflict: "
                                + e.getValue().getConflict());
            }

            InstructionUseInfo useInfo = e.getValue().useInfo;
            RegisterSet toFree;
            if (e.getKey().getName().startsWith("return")) {
                // we want to free everything except what this instruction
                // uses.
                toFree = objectRegs.andNot(useInfo.usedReg());
            } else {
                // we free any register reference that is overwritten by
                // this
                // instruction
                toFree = objectRegs.and(useInfo.allWrites());
            }
            useInfo.willFree = toFree;
            useInfo.willNull = toFree.clone();

        }
    }
}
项目:cn1    文件:ReferenceCounting.java   
@SuppressWarnings("unchecked")
private void clearReleaseRetainOnSyntheticMembers(RunState curRun, Element codeElement)
        throws DataConversionException {
    // Find the synthetic members of the class;
    Element classElement = codeElement.getParentElement().getParentElement();

    HashSet<String> hashSet = new HashSet<String>();

    for (Element elem : (List<Element>) classElement.getChildren()) {
        if (elem.getName().equals("field") && elem.getAttribute("isSynthetic") != null
                && elem.getAttributeValue("isSynthetic").equals("true")
                && elem.getAttributeValue("name").startsWith("this$")) {
            hashSet.add(elem.getAttributeValue("name"));
        }
    }

    for (Map.Entry<Element, InstructionActions> e : curRun.beenTo.entrySet()) {

        String instructionElementName = e.getKey().getName();
        if ((instructionElementName.equals("iput-object") || instructionElementName
                .equals("iput"))
                && e.getKey().getAttribute("member-name") != null
                && hashSet.contains(e.getKey().getAttributeValue("member-name"))) {
            InstructionUseInfo useInfo = e.getValue().useInfo;
            // We don't want to release what was in there because it was not
            // retained
            useInfo.putRelease = null;
            useInfo.requiresRetain = RegisterSet.none();
        }
    }
}
项目:cn1    文件:ReferenceCounting.java   
/**
 * Determines conflicts and retain/release for the method.
 */
private void doMarkup(List<Element> toProcess) throws DataConversionException {
    // create a new run of the processor, prime the recursion, and then
    // run it until its complete.
    curRun = new RunState();
    processRecAdd(RegisterSet.none(), RegisterSet.none(), toProcess.get(0),
            createNewCodePath(null));
    processWhileCallsToDo();
    // Debug print for state at this stage.
    printInstSeq(toProcess);
}
项目:cn1    文件:ReferenceCounting.java   
/**
 * Helper to add to the list of recursive calls to do.
 */
private void processRecAdd(RegisterSet regHoldingObject, RegisterSet regNotHoldingObject,
        Element currentElement, CodePath codePath) throws DataConversionException {
    OneRecusiveCall oneCall = new OneRecusiveCall();
    oneCall.regHoldingObject = regHoldingObject;
    oneCall.regNotHoldingObject = regNotHoldingObject;
    oneCall.currentElement = currentElement;
    oneCall.codePath = codePath;
    this.curRun.callsToDo.add(oneCall);
}
项目:cn1    文件:InstructionProcessor.java   
@SuppressWarnings("unchecked")
static void getUsedFromParams(Element funcCallElement, InstructionUseInfo i)
        throws DataConversionException {

    Element pHolder = funcCallElement.getChild("parameters", dex);

    List<Element> params = (List<Element>) pHolder.getChildren("parameter", dex);
    for (Element parameter : params) {
        i.checkUsage(parameter.getAttribute("register"), parameter.getAttribute("type"));
    }

}
项目:cn1    文件:InstructionProcessor.java   
static public void process_var(Element element, InstructionUseInfo i)
        throws DataConversionException {
    i.isWrite = true;
    i.possibleWrites.clear();
    i.possibleWrites.add("register");
    i.requiresRetain = i.writesObj();
}
项目:cn1    文件:InstructionProcessor.java   
@SuppressWarnings("unchecked")
static public void process_aput_object(Element element, InstructionUseInfo i)
        throws DataConversionException {
    i.requiresRetain.orEq(getDestReg(element, "vx").and(i.usesAsObj()));
    if (!i.requiresRetain.isEmpty()) {

        Element toAdd = new Element(cmd_a_release, vm);
        for (Attribute a : (List<Attribute>) i.Instruction.getAttributes()) {
            toAdd.setAttribute(a.getName(), a.getValue(), a.getNamespace());
        }

        i.putRelease = toAdd;
    }
    i.isWrite = false;
}
项目:cn1    文件:InstructionProcessor.java   
@SuppressWarnings("unchecked")
static public void process_sput(Element element, InstructionUseInfo i)
        throws DataConversionException {
    i.requiresRetain.orEq(getDestReg(element, "vx").and(i.usesAsObj()));
    if (!i.requiresRetain.isEmpty()) {
        // need to release before we overwrite
        Element toAdd = new Element(cmd_s_release, vm);
        for (Attribute a : (List<Attribute>) i.Instruction.getAttributes()) {
            toAdd.setAttribute(a.getName(), a.getValue(), a.getNamespace());
        }
        i.putRelease = toAdd;
    }
    i.isWrite = false;
}
项目:cn1    文件:InstructionProcessor.java   
@SuppressWarnings("unchecked")
static public void process_iput(Element element, InstructionUseInfo i)
        throws DataConversionException {
    i.requiresRetain.orEq(getDestReg(element, "vx").and(i.usesAsObj()));

    if (!i.requiresRetain.isEmpty()) {
        // need to release before we overwrite
        Element toAdd = new Element(cmd_i_release, vm);
        for (Attribute a : (List<Attribute>) i.Instruction.getAttributes()) {
            toAdd.setAttribute(a.getName(), a.getValue(), a.getNamespace());
        }
        i.putRelease = toAdd;
    }
    i.isWrite = false;
}
项目:cn1    文件:InstructionProcessor.java   
@SuppressWarnings("unchecked")
static public void process_filled_new_array(Element element, InstructionUseInfo i)
        throws DataConversionException {
    Element moveResult = element.getChild("move-result", dex);

    for (Element valElement : (List<Element>) element.getChildren("value", dex)) {
        i.checkUsage(valElement.getAttribute("register"), valElement.getAttribute("type"));
    }

    i.checkUsage(moveResult.getAttribute("vx"), moveResult.getAttribute("vx-type"));

    i.isWrite = true;
}
项目:cn1    文件:InstructionUseInfo.java   
/**
 * On construction, we check for the normal vx vy vz register usage patterns
 * present in DEX, adding them to our info store if they exist.
 */
public InstructionUseInfo(Element element) throws DataConversionException {
    this.Instruction = element;

    checkUsage(element.getAttribute("vx"), element.getAttribute("vx-type"));
    checkUsage(element.getAttribute("vy"), element.getAttribute("vy-type"));
    checkUsage(element.getAttribute("vz"), element.getAttribute("vz-type"));
    checkUsage(element.getAttribute("register"), element.getAttribute("type"));
    checkUsage(element.getAttribute("register"), element.getAttribute("class-type"));
    possibleWrites.add("vx");
}
项目:cn1    文件:InstructionUseInfo.java   
/**
 * Given a register attribute and a type attribute, this method adds both to
 * this classes list of register usage. It also determines whether the usage
 * is object or not object depending on the type. In order for all of the
 * ref counting code to work, all register usage everywhere must be
 * registered with this function.
 */
public void checkUsage(Attribute vy, Attribute vyType) throws DataConversionException {
    InstructionUseInfo use = this;
    if (vy != null) {
        if (vyType != null) {
            if (InstructionProcessor.nonObjTypes.matcher(vyType.getValue()).matches()) {
                use.typeIsObj.put(vy, Boolean.FALSE);
            } else {
                use.typeIsObj.put(vy, Boolean.TRUE);
            }
        }
    }
}
项目:cn1    文件:InstructionUseInfo.java   
/**
 * The list of registers this instruction writes with non objects
 */
public RegisterSet writesNonObj() throws DataConversionException {
    if (isWrite) {
        for (Attribute key : typeIsObj.keySet()) {
            for (String s : possibleWrites) {
                if (key.getName().equals(s)) {
                    if (!typeIsObj.get(key)) {
                        return RegisterSet.from(key.getIntValue());
                    }
                }
            }
        }
    }
    return RegisterSet.none();
}
项目:tools-idea    文件:ProjectLevelVcsManagerImpl.java   
public void readExternal(Element element) throws InvalidDataException {
  mySerialization.readExternalUtil(element, myOptionsAndConfirmations);
  final Attribute attribute = element.getAttribute(SETTINGS_EDITED_MANUALLY);
  if (attribute != null) {
    try {
      myHaveLegacyVcsConfiguration = attribute.getBooleanValue();
    }
    catch (DataConversionException e) {
      //
    }
  }
}
项目:lindenmayer    文件:Grammar.java   
/**
 * Reads from XML file. TODO: Extract method to separate class.
 */
public void loadFromXML()
        throws DataConversionException {
    XMLParser xml = new XMLParser(this.file);

    // Load parts of this grammar
    alphabet = xml.getAlphabet();
    rules = xml.getRules();
    startSymbol = xml.getStartSymbol();
}
项目:consulo    文件:ProjectLevelVcsManagerImpl.java   
@Override
public void loadState(Element state) {
  mySerialization.readExternalUtil(state, myOptionsAndConfirmations);
  final Attribute attribute = state.getAttribute(SETTINGS_EDITED_MANUALLY);
  if (attribute != null) {
    try {
      myHaveLegacyVcsConfiguration = attribute.getBooleanValue();
    }
    catch (DataConversionException ignored) {
    }
  }
}
项目:msInspect    文件:PrimitiveConverter.java   
/**
 * Converts String into java primitive type
 * @param type <code>Class</code> target type
 * @param attr <code>Attribute</code> value field needs to provide convertable String
 * @return <code>Object</code> primitive wrapped into wrapper object
 */
public static Object conv( final Class type, final Attribute attr,  final Localizer localizer ) throws Exception {
  Attribute a = (Attribute) attr.clone();
  Object obj = null;
  if ( Parser.LOCALIZED_ATTRIBUTES.contains( a.getName().toLowerCase() ))
    if (a.getAttributeType() == Attribute.CDATA_TYPE )
       a.setValue( localizer.getString( a.getValue() ));

  try {
    if (boolean.class.equals( type )) {
      obj = new Boolean( a.getBooleanValue() );
    } else if (int.class.equals( type )) {
      obj = new Integer( a.getIntValue() );
    } else if (long.class.equals( type )) {
      obj = new Long( a.getLongValue() );
    } else if (float.class.equals( type )) {
      obj = new Float( a.getFloatValue() );
    } else if (double.class.equals( type )) {
      obj = new Double( a.getDoubleValue() );
    }
  } catch (DataConversionException e) {
  } finally {
    if (obj==null) {
      try {
        String s = a.getValue();
        int k = s.indexOf( '.' ) - 1;
        Class pp = (Class) dictionaries.get( s.substring( 0, s.indexOf( '.' ) ) );
        obj = pp.getField( s.substring( k + 2 ) ).get( pp );
      } catch (Exception ex) {
        //
        //  Try to find the given value as a Constant in SwingConstants
        //
        obj = PrimitiveConverter.class.getField( a.getValue() ).get( PrimitiveConverter.class );
      }
    }
  }

  return obj;
}
项目:itsimple    文件:ObjectGridWizard.java   
public ArrayList<Object> getObjectsClass(String id_classe){
       List<?> result, result1, result2, result3= null;
       String classe = null;
       Object[] objects = null;
       ArrayList<Object> objs = new ArrayList<Object>();

try {

           Integer id = null;
           Element domain = diagram.getParentElement().getParentElement();
           try {
               id = domain.getAttribute("id").getIntValue();
           } catch (DataConversionException ex) {
               Logger.getLogger(ObjectGridWizard.class.getName()).log(Level.SEVERE, null, ex);
           }

           XPath path = new JDOMXPath("project/diagrams/planningDomains/domain[@id="+id+"]");
           result1 = path.selectNodes(diagram.getDocument());

           Element object1  = (Element)(result1.get(0));

           result = object1.getChildren("elements");

           Element object2 = (Element)result.get(0);

           result2 = object2.getChildren("objects");

           Element object3 = (Element)result2.get(0);

           result3 = object3.getChildren("object");
                  //
       } 
       catch (JaxenException e2) {          
           }

        for (int i = 0; i < result3.size(); i++){
           Element object = (Element)result3.get(i);
           classe = (object.getChildText("class"));
           if(classe.equals(id_classe))
               objs.add(object.getChildText("name"));
       }
       return objs;   
   }
项目:itsimple    文件:ObjectGridWizard.java   
private Map<Object, ArrayList>  getObjects(){

    ArrayList<String> objects = null;
    List<?> result, result1, result2, result3= null;

    //To save an object and its class associations
    Map<Object, ArrayList> mp=new HashMap<Object, ArrayList>();

    if(diagram!= null){
        try{
            Integer id = null;
            Element domain = diagram.getParentElement().getParentElement();
            try {
                id = domain.getAttribute("id").getIntValue();
                } 
            catch (DataConversionException ex) {
                Logger.getLogger(ObjectGridWizard.class.getName()).log(Level.SEVERE, null, ex);
                }

            XPath path = new JDOMXPath("project/diagrams/planningDomains/domain[@id="+id+"]");
            result1 = path.selectNodes(diagram.getDocument());

            Element object1  = (Element)result1.get(0);

            result = object1.getChildren("elements");

            Element object2 = (Element)result.get(0);

            result2 = object2.getChildren("objects");

            Element object3 = (Element)result2.get(0);

            result3 = object3.getChildren("object");
               //
        } 
        catch (JaxenException e2) {         
            e2.printStackTrace();
        }
        for (int i = 0; i < result3.size(); i++){
            Element object  = (Element)result3.get(i);
            ArrayList <Object> associations = getAssociations(object.getChildText("class").toString());

            if(associations.size() != 0)
                mp.put(object.getChildText("name"), associations);//object.getChildText("class"));
           }
   }
  return mp;
}
项目:itsimple    文件:AssociateNeighbour3.java   
public String getClassObject(String name_object){
    List<?> result, result1, result2, result3= null;
    String name = null;

    try {
        Integer id = null;
        //object Diagram:
        //Element domain = objectDiagram.getParentElement().getParentElement().getParentElement().getParentElement();

        //repository diagram:
        Element domain = objectDiagram.getParentElement().getParentElement();
        try {
            id = domain.getAttribute("id").getIntValue();
        } catch (DataConversionException ex) {
            Logger.getLogger(AssociateNeighbour3.class.getName()).log(Level.SEVERE, null, ex);
        }

        XPath path = new JDOMXPath("project/diagrams/planningDomains/domain[@id="+id+"]");
        result1 = path.selectNodes(objectDiagram.getDocument());

        Element object1  = (Element)(result1.get(0));

        result = object1.getChildren("elements");

        Element object2 = (Element)result.get(0);

        result2 = object2.getChildren("objects");

        Element object3 = (Element)result2.get(0);

        result3 = object3.getChildren("object");
               //
    } 
    catch (JaxenException e2) {         
        }

    for (int i = 0; i < result3.size(); i++){
        Element object = (Element)result3.get(i);
        name = (object.getChildText("name"));
        if(name.equals(name_object)) {
            return object.getChildText("class");
        }
    }
    return null;   
}
项目:itsimple    文件:ObjectGridWizard4.java   
public ArrayList<Object> getObjectsClass(String id_classe){
       List<?> result, result1, result2, result3= null;
       String classe = null;
       Object[] objects = null;
       ArrayList<Object> objs = new ArrayList<Object>();

try {

           Integer id = null;
           Element domain = diagram.getParentElement().getParentElement();
           try {
               id = domain.getAttribute("id").getIntValue();
           } catch (DataConversionException ex) {
               Logger.getLogger(ObjectGridWizard.class.getName()).log(Level.SEVERE, null, ex);
           }

           XPath path = new JDOMXPath("project/diagrams/planningDomains/domain[@id="+id+"]");
           result1 = path.selectNodes(diagram.getDocument());

           Element object1  = (Element)(result1.get(0));

           result = object1.getChildren("elements");

           Element object2 = (Element)result.get(0);

           result2 = object2.getChildren("objects");

           Element object3 = (Element)result2.get(0);

           result3 = object3.getChildren("object");
                  //
       } 
       catch (JaxenException e2) {          
           }

        for (int i = 0; i < result3.size(); i++){
           Element object = (Element)result3.get(i);
           classe = (object.getChildText("class"));
           if(classe.equals(id_classe))
               objs.add(object.getChildText("name"));
       }
       return objs;   
   }
项目:itsimple    文件:ObjectGridWizard4.java   
private Map<Object, ArrayList>  getObjects(){

    ArrayList<String> objects = null;
    List<?> result, result1, result2, result3= null;

    //To save an object and its class associations
    Map<Object, ArrayList> mp=new HashMap<Object, ArrayList>();

    if(diagram!= null){
        try{
            Integer id = null;
            Element domain = diagram.getParentElement().getParentElement();
            try {
                id = domain.getAttribute("id").getIntValue();
                } 
            catch (DataConversionException ex) {
                Logger.getLogger(ObjectGridWizard.class.getName()).log(Level.SEVERE, null, ex);
                }

            XPath path = new JDOMXPath("project/diagrams/planningDomains/domain[@id="+id+"]");
            result1 = path.selectNodes(diagram.getDocument());

            Element object1  = (Element)result1.get(0);

            result = object1.getChildren("elements");

            Element object2 = (Element)result.get(0);

            result2 = object2.getChildren("objects");

            Element object3 = (Element)result2.get(0);

            result3 = object3.getChildren("object");
               //
        } 
        catch (JaxenException e2) {         
            e2.printStackTrace();
        }
        for (int i = 0; i < result3.size(); i++){
            Element object  = (Element)result3.get(i);
            ArrayList <Object> associations = getAssociations(object.getChildText("class").toString());

            if(associations.size() != 0)
                mp.put(object.getChildText("name"), associations);//object.getChildText("class"));
           }
   }
  return mp;
}
项目:cn1    文件:ReferenceCounting.java   
/**
 * In certain cases, DEX will create a code path where we think we need to
 * do a release of an object on a particular register which may or may not
 * hold an object depending on the particular path through the code taken at
 * runtime. There are several ways to approach this issue, the most simple
 * is to split a conflicted register into two new registers. Conceptually,
 * this is done by defining a function that maps RX to RY or RZ depending on
 * whether RX is known to hold an object or a primitive.
 * 
 * The following code implements this mapping, with the slight optimization
 * that instead of mapping RX to RY and RZ, it maps it to RX and RY. This is
 * because it keeps the sequence of registers intact with no holes, and
 * because it allows us to deal with function parameters more easily.
 * 
 * We return the total number of registers required for this method.
 */
int splitConflictedRegisters(int numReg, RegisterSet allConflict,
        Map<Element, InstructionActions> beenTo) throws DataConversionException,
        ReferenceCountingException {

    for (int reg : allConflict) {
        int newReg = numReg++;

        // When dealing with a passed parameter that has a conflict, we want
        // to make sure to not change the register that the parameter is
        // originally inserted into.
        int regObj = reg;
        int regNonObj = newReg;

        for (Element varE : beenTo.keySet()) {
            if (varE.getName().equals("var")) {
                InstructionUseInfo varUi = this.curRun.beenTo.get(varE).useInfo;
                if (varUi.isWrite) {
                    if (!varUi.writesObj().isEmpty()) {
                        regObj = reg;
                        regNonObj = newReg;
                        break;
                    } else if (!varUi.writesNonObj().isEmpty()) {
                        regObj = newReg;
                        regNonObj = reg;
                    } else {
                        throw new ReferenceCountingException("impossible");
                    }
                }
            }
        }

        refLog(reg + " -> o:" + regObj + ":" + regNonObj);

        // Go through all the instructions in the method, replacing any
        // that use the conflicted value with the new register or the old
        // register depending on whether the instruction expects the
        // register to contain an object or a primitive.
        for (Map.Entry<Element, InstructionActions> beenToKv : beenTo.entrySet()) {
            InstructionUseInfo ui = beenToKv.getValue().useInfo;

            for (Map.Entry<Attribute, Boolean> kv : ui.typeIsObj.entrySet()) {
                if (kv.getKey().getIntValue() == reg) {
                    if (kv.getValue()) {
                        // its an object
                        kv.getKey().setValue(regObj + "");
                    } else {
                        kv.getKey().setValue(regNonObj + "");
                    }
                }
            }
        }
    }
    return numReg;
}
项目:cn1    文件:ReferenceCountingException.java   
public ReferenceCountingException(DataConversionException convertEx) {
    this.message = convertEx.getMessage();
}