本文整理汇总了Java中org.jdom.DataConversionException类的典型用法代码示例。如果您正苦于以下问题:Java DataConversionException类的具体用法?Java DataConversionException怎么用?Java DataConversionException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DataConversionException类属于org.jdom包,在下文中一共展示了DataConversionException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getParkingLocation
import org.jdom.DataConversionException; //导入依赖的package包/类
/**
* 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;
}
}
示例2: process
import org.jdom.DataConversionException; //导入依赖的package包/类
/**
* 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);
}
示例3: addToNextPrevElement
import org.jdom.DataConversionException; //导入依赖的package包/类
/**
* 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;
}
}
示例4: processElement
import org.jdom.DataConversionException; //导入依赖的package包/类
/**
* 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;
}
示例5: getMoveResult
import org.jdom.DataConversionException; //导入依赖的package包/类
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;
}
}
示例6: process_iput_object
import org.jdom.DataConversionException; //导入依赖的package包/类
@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;
}
示例7: process_sput_object
import org.jdom.DataConversionException; //导入依赖的package包/类
@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;
}
示例8: writesObj
import org.jdom.DataConversionException; //导入依赖的package包/类
/**
* 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();
}
示例9: toString
import org.jdom.DataConversionException; //导入依赖的package包/类
/**
* 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();
}
示例10: validateSection
import org.jdom.DataConversionException; //导入依赖的package包/类
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;
}
示例11: initRediPoolConfig
import org.jdom.DataConversionException; //导入依赖的package包/类
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;
}
示例12: initRedis
import org.jdom.DataConversionException; //导入依赖的package包/类
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;
}
示例13: main
import org.jdom.DataConversionException; //导入依赖的package包/类
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);
}
示例14: readExternal
import org.jdom.DataConversionException; //导入依赖的package包/类
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) {}
}
}
示例15: readExternal
import org.jdom.DataConversionException; //导入依赖的package包/类
@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) {
//
}
}
}