• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java JDOMParseException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: parseStrictOrSloppyXML

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 * Returns an XML Document, parsed strictly if possible, or sloppily.
 * Exceptions during strict parsing will be ignored.
 *
 * This method does NOT strip the XML declaration and add a wrapper
 * tag with namespaces. That must be done beforehand.
 *
 * @see net.vhati.modmanager.core.EmptyAwareSAXHandlerFactory
 * @see net.vhati.modmanager.core.SloppyXMLParser
 */
public static Document parseStrictOrSloppyXML(CharSequence srcSeq, String srcDescription) throws IOException, JDOMException {
	Document doc;

	try {
		SAXBuilder strictParser = new SAXBuilder();
		strictParser.setSAXHandlerFactory(new EmptyAwareSAXHandlerFactory());
		doc = strictParser.build(new StringReader(srcSeq.toString()));
	}
	catch (JDOMParseException e) {
		// Ignore the error, and do a sloppy parse instead.

		try {
			SloppyXMLParser sloppyParser = new SloppyXMLParser();
			doc = sloppyParser.build(srcSeq);
		}
		catch (JDOMParseException f) {
			throw new JDOMException(String.format("While processing \"%s\", strict parsing failed, then sloppy parsing failed: %s", srcDescription, f.getMessage()), f);
		}
	}

	return doc;
}
 
开发者ID:Niels-NTG,项目名称:FTLAV,代码行数:33,代码来源:TextUtilities.java


示例2: reportGeneralProblem

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
public void reportGeneralProblem(Exception e) {
    String message;
    if (e instanceof IOException || e instanceof JDOMParseException) {
        message = "There was a problem parsing your input data.  \n" +
                "Perhaps check that the XML is well formed.";
    } else if (e instanceof YQueryException) {
        message = e.getMessage();
    } else {
        message = e.getMessage();
    }
    e.printStackTrace();
    JOptionPane.showMessageDialog(
            this,
            message,
            "Problem with data input",
            JOptionPane.ERROR_MESSAGE);
}
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:18,代码来源:YWorklistGUI.java


示例3: findTagsNamed

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
public static ArrayList<Element> findTagsNamed( String contents, String tagName ) throws JDOMParseException
{
	Document doc = null;
	doc = IOUtils.parseXML( contents );
	ArrayList<Element> tagList = new ArrayList<Element>();

	Element root = doc.getRootElement();

	if ( root.getName().equals( tagName ) ) {
		tagList.add( root );
	}
	else {
		for ( Element e : root.getChildren( tagName ) )
			tagList.add( e );
	}

	return tagList;
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:19,代码来源:DataUtils.java


示例4: parseFile

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
public PartialConfig parseFile(File file) {
    FileInputStream inputStream = null;
    try {
        inputStream = new FileInputStream(file);
        return loader.fromXmlPartial(inputStream, PartialConfig.class);
    } catch (JDOMParseException jdomex) {
        throw new RuntimeException("Syntax error in xml file: " + file.getName(), jdomex);
    } catch (IOException ioex) {
        throw new RuntimeException("IO error when trying to parse xml file: " + file.getName(), ioex);
    } catch (Exception ex) {
        throw new RuntimeException("Failed to parse xml file: " + file.getName(), ex);
    } finally {
        if (inputStream != null) try {
            inputStream.close();
        } catch (IOException e) {
            LOGGER.error("Failed to close file: {}", file, e);
        }
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:20,代码来源:XmlPartialConfigProvider.java


示例5: parseStrictOrSloppyXML

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 * Returns an XML Document, parsed strictly if possible, or sloppily.
 * Exceptions during strict parsing will be ignored.
 *
 * This method does NOT strip the XML declaration and add a wrapper
 * tag with namespaces. That must be done beforehand.
 *
 * @see net.vhati.modmanager.core.EmptyAwareSAXHandlerFactory
 * @see net.vhati.modmanager.core.SloppyXMLParser
 */
public static Document parseStrictOrSloppyXML( CharSequence srcSeq, String srcDescription ) throws IOException, JDOMException {
	Document doc = null;

	try {
		SAXBuilder strictParser = new SAXBuilder();
		strictParser.setSAXHandlerFactory( new EmptyAwareSAXHandlerFactory() );
		doc = strictParser.build( new StringReader( srcSeq.toString() ) );
	}
	catch ( JDOMParseException e ) {
		// Ignore the error, and do a sloppy parse instead.

		try {
			SloppyXMLParser sloppyParser = new SloppyXMLParser();
			doc = sloppyParser.build( srcSeq );
		}
		catch ( JDOMParseException f ) {
			throw new JDOMException( String.format( "While processing \"%s\", strict parsing failed, then sloppy parsing failed: %s", srcDescription, f.getMessage() ), f );
		}
	}

	return doc;
}
 
开发者ID:Vhati,项目名称:Slipstream-Mod-Manager,代码行数:33,代码来源:ModUtilities.java


示例6: suppressStackTrace

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
@Override
public boolean suppressStackTrace() {
    // Don't dump the stack if the root cause is just a parse error
    Throwable thrown = getThrown();
    while(thrown instanceof InvalidXMLException) thrown = thrown.getCause();
    return thrown == null ||
           (thrown instanceof JDOMParseException) ||
           super.suppressStackTrace();
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:MapLogRecord.java


示例7: validateXML

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
private String validateXML(String xml, SAXBuilder builder) throws JDOMException, IOException {
   Reader in;
   int i = 0;

   xml = xml.replaceAll("\\&", "&amp;");
   
   while (i < 5) {
    in = new StringReader(xml);
   	
   	try {
   		builder.build(in);
   		break;
   	} catch (JDOMParseException e) {
   		String message = e.getMessage();
   		if (message.matches("^.*.The element type.*.must be terminated by the matching end-tag.*")) {
   			String tag = message.substring(message.lastIndexOf("type") + 6, message.lastIndexOf("must") - 2);
   			xml = xml.replaceAll("(?i)</" + tag + ">" , "</" + tag + ">");
   		} else {
   			break;
   		}
   		
   		i++;
   	}
   }
   
return xml;
  }
 
开发者ID:wseemann,项目名称:JavaPlaylistParser,代码行数:28,代码来源:ASXPlaylistParser.java


示例8: saveShipModFTL

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 * Saves the ship within the context of the specified database entry, as the specified file.
 * 
 * @param destination
 *            the output file.
 * @param entry
 *            the DatabaseEntry (runtime representation of an .ftl mod) within which the ship is to be saved.
 * @param container
 *            the ShipContainer to be saved.
 */
public static void saveShipModFTL( File destination, DatabaseEntry entry, ShipContainer container )
	throws IllegalArgumentException, IOException, JDOMParseException
{
	if ( destination == null )
		throw new IllegalArgumentException( "Destination file must not be null." );
	if ( destination.isDirectory() )
		throw new IllegalArgumentException( "Not a file: " + destination.getName() );

	HashMap<String, byte[]> entryMap = IOUtils.readEntry( entry );
	IOUtils.merge( entryMap, container );
	IOUtils.writeZip( entryMap, destination );
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:23,代码来源:ShipSaveUtils.java


示例9: saveShipModXML

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
public static void saveShipModXML( File destination, DatabaseEntry entry, ShipContainer container )
	throws IllegalArgumentException, IOException, JDOMParseException
{
	if ( destination == null )
		throw new IllegalArgumentException( "Destination file must not be null." );
	if ( !destination.isDirectory() )
		throw new IllegalArgumentException( "Not a directory: " + destination.getName() );

	HashMap<String, byte[]> entryMap = IOUtils.readEntry( entry );
	IOUtils.merge( entryMap, container );
	IOUtils.writeDir( entryMap, destination );
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:13,代码来源:ShipSaveUtils.java


示例10: shouldNotAllowEmptyAuthInApproval

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
@Test
public void shouldNotAllowEmptyAuthInApproval() throws Exception {
    CruiseConfig cruiseConfig = ConfigMigrator.load(ConfigFileFixture.ONE_PIPELINE);
    StageConfig stageConfig = com.thoughtworks.go.helper.StageConfigMother.custom("newStage", new AuthConfig());
    cruiseConfig.pipelineConfigByName(new CaseInsensitiveString("pipeline1")).add(stageConfig);

    try {
        xmlWriter.write(cruiseConfig, output, false);
        assertThat("Should not allow approval with empty auth", output.toString().contains("<auth"), is(false));
    } catch (JDOMParseException expected) {
        assertThat(expected.getMessage(), containsString("The content of element 'auth' is not complete"));
    }
}
 
开发者ID:gocd,项目名称:gocd,代码行数:14,代码来源:MagicalGoConfigXmlWriterTest.java


示例11: shouldThrowExceptionWhenXmlIsMalformed

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
@Test
public void shouldThrowExceptionWhenXmlIsMalformed() throws Exception {
    expectedException.expect(JDOMParseException.class);
    expectedException.expectMessage(containsString("Error on line 1: XML document structures must start and end within the same entity"));

    String xmlContent = "<foo name='invalid'";
    buildXmlDocument(xmlContent, GoConfigSchema.getCurrentSchema());
}
 
开发者ID:gocd,项目名称:gocd,代码行数:9,代码来源:XmlUtilsTest.java


示例12: fromJDOM

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
public static InvalidXMLException fromJDOM(JDOMParseException e, String documentPath) {
    return new InvalidXMLException(e.getMessage(), null, e.getPartialDocument(), documentPath, e.getLineNumber(), e.getLineNumber(), e.getColumnNumber(), e);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:InvalidXMLException.java


示例13: convertHtmlTextToXhtml

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 *
 * @param text      text to convert to HTML
 * @return
 */
public static List<Element> convertHtmlTextToXhtml(String text) {
  List<Element> result = null;

  // if (logger.isTraceEnabled())
  //   logger.trace("Comment to convert: " + Database.stringToHex(text));
  if (Helper.isNotNullOrEmpty(text)) {
    if (!text.startsWith("<")) {
      // plain text
      if (logger.isTraceEnabled())logger.trace("convertHtmlTextToXhtml: plain text");
      StringBuffer sb = new StringBuffer();
      if (Helper.isNotNullOrEmpty(text)) {
        List<String> strings = Helper.tokenize(text, "\n", true);
        for (String string : strings) {
          if (Helper.isNullOrEmpty(string)) {
             sb.append("<p />");
          } else {
            sb.append("<p>");
            sb.append(string);
            sb.append("</p>\n");
          }
        }
      }
      text = sb.toString();
    }

    // tidy the text
    if (logger.isTraceEnabled()) logger.trace("convertHtmlTextToXhtml: tidy the text");
    try {
      String noNL = text.replaceAll("\\n","");
      result = tidyInputStream(new ByteArrayInputStream(noNL.getBytes("utf-8")));
      // result = tidyInputStream(new ByteArrayInputStream(text.getBytes("utf-8")));
      String afterTIDY = result.toString();
      int dummy = 1;
    } catch (JDOMParseException j) {
      if (logger.isDebugEnabled()) logger.trace("convertHtmlTextToXhtml: caught JDOMParseException in the tidy process");
      if (logger.isTraceEnabled()) logger.trace( "" + j);
      tidyForTidyInputStream = null;    // Force a new clean object to be gebnerated for next time around
    } catch (Exception ee) {
      if (logger.isDebugEnabled()) logger.debug("convertHtmlTextToXhtml: caught exception in the tidy process", ee);
      tidyForTidyInputStream = null;    // Force a new clean object to be gebnerated for next time around
    } catch (Throwable t) {
      logger.error("convertHtmlTextToXhtml: caught throwable in the tidy process", t);
      tidyForTidyInputStream = null;    // Force a new clean object to be gebnerated for next time around
    }

    if (result != null) {
      if (logger.isTraceEnabled()) logger.trace("convertHtmlTextToXhtml: returning XHTML");
    } else {
      if (Helper.isNotNullOrEmpty(text)) logger.debug("convertHtmlTextToXhtml: Cannot convert comment text\n" + text);
    }
  }
  return result;
}
 
开发者ID:calibre2opds,项目名称:calibre2opds,代码行数:59,代码来源:JDOMManager.java


示例14: findShipsWithName

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
public static ArrayList<Element> findShipsWithName( File f, String blueprintName )
	throws IllegalArgumentException, JDOMParseException, IOException
{
	return findShipsWithName( blueprintName, new FileInputStream( f ), f.getName() );
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:6,代码来源:DataUtils.java


示例15: merge

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 * Merges the file-byte map with the specified ShipContainer, effectively saving
 * the ship in the file-byte map.
 */
public static void merge( Map<String, byte[]> base, ShipContainer container )
	throws JDOMParseException, IOException
{
	ShipObject ship = container.getShipController().getGameObject();
	Map<String, byte[]> fileMap = ShipSaveUtils.saveShip( container );

	for ( String file : fileMap.keySet() ) {
		if ( base.containsKey( file ) ) {
			// Mod already contains that file; need to consider further
			if ( file.endsWith( ".png" ) || file.equals( ship.getLayoutTXT() ) || file.equals( ship.getLayoutXML() ) ) {
				// Overwrite graphics and layout files
				base.put( file, fileMap.get( file ) );
			}
			else if ( file.endsWith( ".xml" ) || file.endsWith( ".append" ) ||
				file.endsWith( ".rawappend" ) || file.endsWith( ".rawclobber" ) ) {
				// Merge XML files, while removing obscured elements
				Document docBase = IOUtils.parseXML( new String( base.get( file ) ) );
				Document docAdd = IOUtils.parseXML( new String( fileMap.get( file ) ) );

				Element root = docBase.getRootElement();

				List<Content> addList = docAdd.getContent();
				for ( int i = 0; i < addList.size(); ++i ) {
					Content c = addList.get( i );
					if ( c instanceof Element == false )
						continue;
					Element e = (Element)c;

					String name = e.getAttributeValue( "name" );
					if ( name == null ) {
						// Can't identify; just add it.
						e.detach();
						root.addContent( e );
					}
					else {
						// Remove elements that are obscured, in order to prevent bloating
						List<Element> baseList = root.getChildren( e.getName(), e.getNamespace() );
						for ( int j = 0; j < baseList.size(); ++j ) {
							Element el = baseList.get( j );
							String name2 = el.getAttributeValue( "name" );
							if ( name2 != null && name2.equals( name ) ) {
								el.detach();
							}
						}
						e.detach();
						root.addContent( e );
					}
				}

				base.put( file, readDocument( docBase ).getBytes() );
			}
		}
		else {
			// Doesn't exist; add it
			base.put( file, fileMap.get( file ) );
		}
	}
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:63,代码来源:IOUtils.java


示例16: goConfigServiceWithInvalidStatus

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
private GoConfigService goConfigServiceWithInvalidStatus() throws Exception {
    goConfigDao = mock(GoConfigDao.class, "badCruiseConfigManager");
    when(goConfigDao.checkConfigFileValid()).thenReturn(GoConfigValidity.invalid(new JDOMParseException("JDom exception", new RuntimeException())));
    return new GoConfigService(goConfigDao, pipelineRepository, new SystemTimeClock(), mock(GoConfigMigration.class), goCache, null,
            ConfigElementImplementationRegistryMother.withNoPlugins(), instanceFactory, null, null);
}
 
开发者ID:gocd,项目名称:gocd,代码行数:7,代码来源:GoConfigServiceTest.java


示例17: expectDOCTYPEDisallowedException

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
private void expectDOCTYPEDisallowedException() {
    expectedException.expect(JDOMParseException.class);
    expectedException.expectMessage(containsString("DOCTYPE is disallowed when the feature \"http://apache.org/xml/features/disallow-doctype-decl\" set to true"));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:5,代码来源:XmlUtilsTest.java


示例18: loadLayoutXML

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 * 
 * @param ship
 *            ship object in which the loaded data will be saved
 * @param f
 *            file from which the data is read
 * @throws IllegalArgumentException
 *             when the file is wrongly formatted - a tag or an attribute is missing
 * @throws JDOMParseException
 *             when a parsing error occurs
 * @throws IOException
 *             when a general IO error occurs
 */
public static void loadLayoutXML( ShipObject ship, File f ) throws IllegalArgumentException, JDOMParseException, IOException
{
	if ( ship == null )
		throw new IllegalArgumentException( "Ship object must not be null." );
	if ( f == null )
		throw new IllegalArgumentException( "File must not be null." );
	loadLayoutXML( ship, new FileInputStream( f ) );
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:22,代码来源:ShipLoadUtils.java


示例19: parseXML

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 * Interprets the string as XML.
 * 
 * @param contents
 *            the string to be interpreted
 * @return the XML document representing the string
 * 
 * @throws JDOMParseException
 *             when an exception occurs while parsing XML
 */
public static Document parseXML( String contents ) throws JDOMParseException
{
	if ( contents == null )
		throw new IllegalArgumentException( "Parsed string must not be null." );

	SloppyXMLParser parser = new SloppyXMLParser();

	return parser.build( contents );
}
 
开发者ID:kartoFlane,项目名称:superluminal2,代码行数:20,代码来源:IOUtils.java


示例20: getLineNumber

import org.jdom2.input.JDOMParseException; //导入依赖的package包/类
/**
 * Returns the line number of the end of the text where the parse error occurred.
 * <p>
 * The first line in the document is line 1.
 * </p>
 *
 * @return an integer representing the line number, or -1 if the information is not available.
 */
public int getLineNumber() {
    if (getCause() instanceof JDOMParseException) {
        return ((JDOMParseException) getCause()).getLineNumber();
    } else {
        return -1;
    }
}
 
开发者ID:rometools,项目名称:rome,代码行数:16,代码来源:ParsingFeedException.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CertStoreHelper类代码示例发布时间:2022-05-22
下一篇:
Java ServiceTypeListenerStatus类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap