当前位置: 首页>>代码示例>>Java>>正文


Java CannotResolveClassException类代码示例

本文整理汇总了Java中com.thoughtworks.xstream.mapper.CannotResolveClassException的典型用法代码示例。如果您正苦于以下问题:Java CannotResolveClassException类的具体用法?Java CannotResolveClassException怎么用?Java CannotResolveClassException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CannotResolveClassException类属于com.thoughtworks.xstream.mapper包,在下文中一共展示了CannotResolveClassException类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testBarfsIfItDoesNotExist

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
public void testBarfsIfItDoesNotExist() {

        String xml = "" +
                "<X-array>\n" +
                "  <X>\n" +
                "    <anInt>0</anInt>\n" +
                "  </X>\n" +
                "</X-array>";

        // now change the alias
        xstream.alias("Xxxxxxxx", X.class);
        try {
            xstream.fromXML(xml);
            fail("ShouldCannotResolveClassException expected");
        } catch (CannotResolveClassException expectedException) {
            // expected
        }
    }
 
开发者ID:x-stream,项目名称:xstream,代码行数:19,代码来源:AliasTest.java

示例2: convertXStreamException

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
/**
    * Convert the given XStream exception to an appropriate exception from the
    * {@code org.springframework.oxm} hierarchy.
    * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
    * unmarshalling, since XStream itself does not make this distinction in its exception hierarchy.
    * @param ex XStream exception that occurred
    * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
    * or unmarshalling ({@code false})
    * @return the corresponding {@code XmlMappingException}
    */
protected XmlMappingException convertXStreamException(Exception ex, boolean marshalling) {
	if (ex instanceof StreamException || ex instanceof CannotResolveClassException ||
			ex instanceof ConversionException) {
		if (marshalling) {
			return new MarshallingFailureException("XStream marshalling exception",  ex);
		}
		else {
			return new UnmarshallingFailureException("XStream unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown XStream exception", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:26,代码来源:XStreamMarshaller.java

示例3: generateXStream

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
/**
 * {@link XStream} generator
 * <p>
 * 
 * @param hierarchicalStreamDriver
 *            {@link HierarchicalStreamDriver}
 * @return {@link XStream}
 */
private XStream generateXStream(HierarchicalStreamDriver hierarchicalStreamDriver) {
    XStream xStream = new XStream(hierarchicalStreamDriver) {
        @Override
        protected MapperWrapper wrapMapper(MapperWrapper next) {
            return new MapperWrapper(next) {
                @Override
                // avoid {@link XStream} crash when field misses
                public boolean shouldSerializeMember(Class definedIn, String fieldName) {
                    try {
                        return definedIn != Object.class || realClass(fieldName) != null;
                    }
                    catch (CannotResolveClassException cnrce) {
                        return false;
                    }
                }
            };
        }
    };
    xStream.autodetectAnnotations(true);

    return xStream;
}
 
开发者ID:owen-chen,项目名称:crawl-center,代码行数:31,代码来源:BaseParser.java

示例4: convertXStreamException

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
/**
    * Convert the given XStream exception to an appropriate exception from the
    * {@code org.springframework.oxm} hierarchy.
    * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
    * unmarshalling, since XStream itself does not make this distinction in its exception hierarchy.
    * @param ex XStream exception that occured
    * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
    * or unmarshalling ({@code false})
    * @return the corresponding {@code XmlMappingException}
    */
protected XmlMappingException convertXStreamException(Exception ex, boolean marshalling) {
	if (ex instanceof StreamException || ex instanceof CannotResolveClassException ||
			ex instanceof ConversionException) {
		if (marshalling) {
			return new MarshallingFailureException("XStream marshalling exception",  ex);
		}
		else {
			return new UnmarshallingFailureException("XStream unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown XStream exception", ex);
	}
}
 
开发者ID:deathspeeder,项目名称:class-guard,代码行数:26,代码来源:XStreamMarshaller.java

示例5: convertSyntaxException

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
/**
 * We don't want to expose the conversion exceptions, so let's translate them into our own exception...
 */
private NaaccrIOException convertSyntaxException(ConversionException ex) {
    String msg = ex.get("message");

    // reading a file that has bad tags is very common, so let's try to get a better error message in that case:
    if (CannotResolveClassException.class.getName().equals(ex.get("cause-exception")))
        msg = "invalid tag: " + ex.get("cause-message");
    else if (StreamException.class.getName().equals(ex.get("cause-exception")))
        msg = "invalid XML syntax";

    if (msg == null)
        msg = ex.getMessage();

    NaaccrIOException e = new NaaccrIOException(msg, ex);
    if (ex.get("line number") != null)
        e.setLineNumber(Integer.valueOf(ex.get("line number")));
    e.setPath(ex.get("path"));
    return e;
}
 
开发者ID:imsweb,项目名称:naaccr-xml,代码行数:22,代码来源:PatientXmlReader.java

示例6: realClass

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
public Class realClass(String elementName) {
    try {
        if (elementName.startsWith(XSTREAM_PACKAGE_ROOT)) {
            return DefaultMapper.class.getClassLoader().loadClass(elementName);
        } else if (elementName.charAt(0) != '[') {
            return classLoader.loadClass(elementName);
        } else if (elementName.endsWith(";")) {
            return Class.forName(elementName.toString(), false, classLoader.getClassLoader());
        } else { 
            return Class.forName(elementName.toString());
        }
    } catch (ClassNotFoundException e) {
        throw new CannotResolveClassException(elementName);
    }
}
 
开发者ID:intrack,项目名称:BoofCV-master,代码行数:16,代码来源:DefaultMapper.java

示例7: fromString

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
@Override
public Object fromString(final String str) {
    try {
        return mapper.realClass(str);
    } catch (final CannotResolveClassException e) {
        throw new ConversionException("Cannot load java class " + str, e.getCause());
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:9,代码来源:JavaClassConverter.java

示例8: testInjectingReplacements

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
public void testInjectingReplacements() {
    XStream xstream = new XStream() {

        protected MapperWrapper wrapMapper(MapperWrapper next) {
            return new MapperWrapper(next) {
                public Class realClass(String elementName) {
                    try {
                        return super.realClass(elementName);

                    } catch (CannotResolveClassException e) {
                        if (elementName.endsWith("oo")) {
                            return Integer.class;
                        }
                        if (elementName.equals("UnknownList")) {
                            return LinkedList.class;
                        }
                        throw e;
                    }
                }
                
            };
        }

    };
    setupSecurity(xstream);
    xstream.alias("wl", WithList.class);
    WithList wl = (WithList)xstream.fromXML("" 
            + "<wl>\n" 
            + "  <things class='UnknownList'>\n" 
            + "    <foo>1</foo>\n" 
            + "    <cocoo>2</cocoo>\n" 
            + "  </things>\n" 
            + "</wl>");
    assertEquals(new ArrayList(Arrays.asList(new Integer[]{new Integer(1), new Integer(2)})), wl.things);
    assertTrue(wl.things instanceof LinkedList);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:37,代码来源:CustomMapperTest.java

示例9: testDebugMessageIsNotNested

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
public void testDebugMessageIsNotNested() {
    Exception ex = new CannotResolveClassException("JUnit");
    ConversionException innerEx = new ConversionException("Inner", ex);
    ConversionException outerEx = new ConversionException("Outer", innerEx);
    StringTokenizer tokenizer = new StringTokenizer(outerEx.getMessage(), "\n\r");
    int ends = 0;
    while(tokenizer.hasMoreTokens()) {
        if (tokenizer.nextToken().startsWith("---- Debugging information ----")) {
            ++ends;
        }
    }
    assertEquals(1, ends);
}
 
开发者ID:x-stream,项目名称:xstream,代码行数:14,代码来源:ConversionExceptionTest.java

示例10: fromString

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
public Object fromString(String paramString)
{
  try
  {
    Class localClass = this.mapper.realClass(paramString);
    return localClass;
  }
  catch (CannotResolveClassException localCannotResolveClassException)
  {
    throw new ConversionException("Cannot load java class " + paramString, localCannotResolveClassException.getCause());
  }
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:13,代码来源:JavaClassConverter.java

示例11: readDocument

import com.thoughtworks.xstream.mapper.CannotResolveClassException; //导入依赖的package包/类
@Override
public void readDocument(InputStream is) {
	XStream streamer = getTagStreamer();
	try {
		tagSet = (StyledTagSet) streamer.fromXML(is);
	} catch (CannotResolveClassException e) {
		throw new RuntimeException("failed to read XML, element "
								   + e.getMessage());
	}
}
 
开发者ID:BrainTech,项目名称:svarog,代码行数:11,代码来源:TagDocument.java


注:本文中的com.thoughtworks.xstream.mapper.CannotResolveClassException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。