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


Java JRXmlUtils.parse方法代码示例

本文整理汇总了Java中net.sf.jasperreports.engine.util.JRXmlUtils.parse方法的典型用法代码示例。如果您正苦于以下问题:Java JRXmlUtils.parse方法的具体用法?Java JRXmlUtils.parse怎么用?Java JRXmlUtils.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.jasperreports.engine.util.JRXmlUtils的用法示例。


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

示例1: getFields

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
	Throwable t = null;
	ArrayList<JRDesignField> fields = new ArrayList<JRDesignField>();
	try {
		String fileName = getDataAdapter().getFileName();
		Document doc = JRXmlUtils.parse(new URL(fileName), XMLUtils.isNamespaceAware(getDataAdapter(), jConfig.getJasperDesign()));
		fields.addAll(getFieldsFromDocument(doc, jConfig, jDataset));
	} catch (IOException e) {
		t = e;
	}

	if (t != null) {
		UIUtils.showError(t);
	}
	return fields;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:18,代码来源:RemoteXMLDataAdapterDescriptor.java

示例2: createCheckboxes

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
protected void createCheckboxes(Properties prop){
	Integer connectionIndex = 0;
	String connectionXML = prop.getProperty("connection." + connectionIndex); //$NON-NLS-1$
	while(connectionXML != null){
		try {
			Document document = JRXmlUtils.parse(new InputSource(new StringReader(connectionXML)));
			NamedNodeMap rootAttributes = document.getChildNodes().item(0).getAttributes();
			String connectionName = rootAttributes.getNamedItem("name").getTextContent(); //$NON-NLS-1$
			String connectionClass = rootAttributes.getNamedItem("connectionClass").getTextContent(); //$NON-NLS-1$
			if (ImportUtility.hasAdapter(connectionClass)){
				Button checkButton = new Button(content, SWT.CHECK);
				String type = connectionClass.substring(connectionClass.lastIndexOf(".")+1); //$NON-NLS-1$
				checkButton.setText(connectionName+" ("+ type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
				checkButton.setData(document);
				selectedElements.add(checkButton);
			}
		} catch (JRException e) {}
		connectionIndex++;
		connectionXML = prop.getProperty("connection." + connectionIndex); //$NON-NLS-1$
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:22,代码来源:ShowAdaptersPage.java

示例3: createCheckboxes

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
protected void createCheckboxes(Properties prop){
	String connectionXML = prop.getProperty("dataAdapters"); //$NON-NLS-1$
	Document document;
	try {
		document = JRXmlUtils.parse(new InputSource(new StringReader(connectionXML)));
		Node actualNode = document.getFirstChild();
		if (actualNode.hasChildNodes()) actualNode = actualNode.getFirstChild();
		else actualNode = null;
		while(actualNode != null){
			if (actualNode.getAttributes() != null){
				String name = actualNode.getChildNodes().item(0).getTextContent();
				String type = actualNode.getAttributes().getNamedItem("class").getTextContent();
				type = type.substring(type.lastIndexOf(".")+1);
				Button checkButton = new Button(content, SWT.CHECK);
				checkButton.setText(name+" ("+ type + ")"); //$NON-NLS-1$ //$NON-NLS-2$
				checkButton.setData(actualNode);
				selectedElements.add(checkButton);
			}
			actualNode = actualNode.getNextSibling();
		}
	} catch (JRException e) {
		e.printStackTrace();
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:25,代码来源:ShowJSSAdaptersPage.java

示例4: loadPreferences

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
/**
 * Load the list of the template set from the preferences file. If one of them has the default 
 * attribute set to true then it will be the selected default. If more of them has the attribute
 * to true only the last one will be the default. A template set is added to the available ones
 * only if it's file exist
 */
private void loadPreferences(){
	String defaults = prefs.get(DEFAULT_KEY, "");
	availableDefaults = new ArrayList<String>();
	if (!defaults.isEmpty()){
		try {
			Document document = JRXmlUtils.parse(new InputSource(new StringReader(defaults)));
			NodeList adapterNodes = document.getDocumentElement().getChildNodes();
			for (int i = 0; i < adapterNodes.getLength(); ++i) {
				Node adapterNode = adapterNodes.item(i);
				if (adapterNode.getNodeType() == Node.ELEMENT_NODE) {
					String path = adapterNode.getAttributes().getNamedItem("path").getNodeValue(); //$NON-NLS-1$
					String defaultReport = adapterNode.getAttributes().getNamedItem("default").getNodeValue(); //$NON-NLS-1$
					//Check file existence
					if (new File(path).exists()){
						availableDefaults.add(path);
						if (Boolean.parseBoolean(defaultReport)) actualDefault = path;
					}
				}
			}
		} catch (JRException e) {
			e.printStackTrace();
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:31,代码来源:DefaultManager.java

示例5: fill

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
/**
 *
 */
public void fill() throws JRException
{
	long start = System.currentTimeMillis();
	Map<String, Object> params = new HashMap<String, Object>();
	Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream("data/northwind.xml"));
	params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
	params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "yyyy-MM-dd");
	params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
	params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
	params.put(JRParameter.REPORT_LOCALE, Locale.US);
	
	JasperFillManager.fillReportToFile("build/reports/CustomersReport.jasper", params);
	System.err.println("Filling time : " + (System.currentTimeMillis() - start));
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:18,代码来源:XmlDataSourceApp.java

示例6: loadDataDocument

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
protected Document loadDataDocument(XmlDataAdapter xmlDataAdapter, Map<String, Object> parameters) throws JRException
{
	DataFileUtils dataFileUtils = DataFileUtils.instance(getParameterContributorContext());
	DataFileStream dataStream = dataFileUtils.getDataStream(
			xmlDataAdapter.getDataFile(), parameters);
	try
	{
		Document dataDocument = JRXmlUtils.parse(dataStream, xmlDataAdapter.isNamespaceAware());
		return dataDocument;
	}
	finally
	{
		dataStream.dispose();
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:16,代码来源:XmlDataAdapterService.java

示例7: JRXmlDataSource

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
public JRXmlDataSource(
		JasperReportsContext jasperReportsContext,
		InputStream in, 
		String selectExpression,
		boolean isNamespaceAware
		) throws JRException 
{
	this(jasperReportsContext, JRXmlUtils.parse(new InputSource(in), isNamespaceAware), selectExpression);
	
	this.inputStream = in;
	this.closeInputStream = false;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:13,代码来源:JRXmlDataSource.java

示例8: loadServerProfiles

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
public static void loadServerProfiles(MServers root) {
	root.removeChildren();
	serverProfiles.clear();

	Preferences prefs = PropertiesHelper.INSTANCE_SCOPE.getNode(JaspersoftStudioPlugin.getUniqueIdentifier());

	String xml = prefs.get(PREF_TAG, null); //$NON-NLS-1$

	if (xml != null) {
		try {
			Document document = JRXmlUtils.parse(new InputSource(new StringReader(xml)));

			NodeList adapterNodes = document.getDocumentElement().getChildNodes();// .getElementsByTagName("dataAdapter");

			for (int i = 0; i < adapterNodes.getLength(); ++i) {
				Node adapterNode = adapterNodes.item(i);

				if (adapterNode.getNodeType() == Node.ELEMENT_NODE) {
					try {
						ServerProfile sprof = (ServerProfile) CastorUtil.read(adapterNode, MServerProfile.MAPPINGFILE);

						MServerProfile sp = new MServerProfile(root, sprof);
						new MDummy(sp);
						serverProfiles.add(sp);
					} catch (Exception ex) {
						ex.printStackTrace();
					}
				}
			}

		} catch (JRException e) {
			UIUtils.showError(e);
		}
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:36,代码来源:ServerManager.java

示例9: getFields

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
@Override
public List<JRDesignField> getFields(DataAdapterService con, JasperReportsConfiguration jConfig, JRDataset jDataset) throws JRException, UnsupportedOperationException {
	setRecursiveRetrieval(jConfig);
	ArrayList<JRDesignField> fields = new ArrayList<JRDesignField>();
	String fileName = getDataAdapter().getFileName();
	File in = new File(fileName);
	Document doc = JRXmlUtils.parse(in, XMLUtils.isNamespaceAware(getDataAdapter(), jConfig.getJasperDesign()));
	fields.addAll(getFieldsFromDocument(doc, jConfig, jDataset));
	return fields;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:11,代码来源:XMLDataAdapterDescriptor.java

示例10: findAll

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
/**
 * Read all the styles from the properties file
 */
private void findAll() {
	try {
		String xml = prefs.get(PREF_KEYS_STYLES, null);
		if (xml != null) {
			Document document = JRXmlUtils.parse(new InputSource(new StringReader(xml)));

			NodeList adapterNodes = document.getDocumentElement().getChildNodes();
			for (int i = 0; i < adapterNodes.getLength(); ++i) {
				Node adapterNode = adapterNodes.item(i);
				if (adapterNode.getNodeType() == Node.ELEMENT_NODE) {
					// 1. Find out the class of this styles...
					String className = adapterNode.getAttributes().getNamedItem("type").getNodeValue(); //$NON-NLS-1$
					TemplateStyle factory = getBuilder(className); 
					if (factory != null){
						TemplateStyle readStyle = factory.buildFromXML(adapterNode);
						Integer uniequeTemplateId = getId();
						readStyle.storePropertiy(STYLE_ID, uniequeTemplateId);
						styleDescriptors.put(uniequeTemplateId, readStyle);
					}
				}
			}

		} else {
			prefs.put(PREF_KEYS_STYLES, "<templateStyles></templateStyles>");
			prefs.flush();
		}
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:34,代码来源:PreferencesTemplateStylesStorage.java

示例11: readTemplateFromFile

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
public List<TemplateStyle> readTemplateFromFile(String xml) {
	List<TemplateStyle> result = new ArrayList<TemplateStyle>();
	try {
		if (xml != null) {
			Document document = JRXmlUtils.parse(new InputSource(new StringReader(xml)));
			NodeList adapterNodes = document.getDocumentElement().getChildNodes();
			for (int i = 0; i < adapterNodes.getLength(); ++i) {
				Node adapterNode = adapterNodes.item(i);
				if (adapterNode.getNodeType() == Node.ELEMENT_NODE && adapterNode.getAttributes().getNamedItem("type")!=null) {
					// 1. Find out the class of this styles...
					String className = adapterNode.getAttributes().getNamedItem("type").getNodeValue(); //$NON-NLS-1$
					TemplateStyle factory = getBuilder(className); 
					if (factory != null){
						TemplateStyle readStyle = factory.buildFromXML(adapterNode);
						Integer uniequeTemplateId = getId();
						readStyle.storePropertiy(STYLE_ID, uniequeTemplateId);
						result.add(readStyle);
					}
				}
			}

		} 
	} catch (Exception e) {
		e.printStackTrace();
	}
	return result;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:28,代码来源:PreferencesTemplateStylesStorage.java

示例12: readDataFile

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
protected Map<String, Object> readDataFile(String xmlDataFile) throws JRException {
    Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream(xmlDataFile));
    Map<String, Object> params = new HashMap<String, Object>();
    params.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
    params.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, "yyyy-MM-dd");
    params.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, "#,##0.##");
    params.put(JRXPathQueryExecuterFactory.XML_LOCALE, Locale.ENGLISH);
    params.put(JRParameter.REPORT_LOCALE, Locale.US);
    return params;
}
 
开发者ID:stefanorosanelli,项目名称:jasper-service,代码行数:11,代码来源:JasperProcess.java

示例13: contributeParameters

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
@Override
public void contributeParameters(Map<String, Object> parameters) throws JRException 
{
	RemoteXmlDataAdapter remoteXmlDataAdapter = getRemoteXmlDataAdapter();
	if (remoteXmlDataAdapter != null)
	{
		if (remoteXmlDataAdapter.isUseConnection()) 
		{
			String fileName = remoteXmlDataAdapter.getFileName();
			if (fileName.toLowerCase().startsWith("https://") ||
				fileName.toLowerCase().startsWith("http://") ||
				fileName.toLowerCase().startsWith("file:")) {
				
				// JRXPathQueryExecuterFactory.XML_URL not available.
				// Once this is available, remove XML_URL from this class.
				parameters.put(XML_URL, fileName);
			}
			else 
			{
				InputStream dataStream = RepositoryUtil.getInstance(getJasperReportsContext()).getInputStreamFromLocation(remoteXmlDataAdapter.getFileName());
				try
				{
					Document document = JRXmlUtils.parse(dataStream, remoteXmlDataAdapter.isNamespaceAware());
					parameters.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);
				}
				finally
				{
					try
					{
						dataStream.close();
					}
					catch (IOException e)
					{
						log.warn("Failed to close input stream for " + remoteXmlDataAdapter.getFileName());
					}
				}
			}
			
			Locale locale = remoteXmlDataAdapter.getLocale();
			if (locale != null) {
				parameters.put(JRXPathQueryExecuterFactory.XML_LOCALE, locale);
			}

			TimeZone timeZone = remoteXmlDataAdapter.getTimeZone();
			if (timeZone != null) {
				parameters.put(JRXPathQueryExecuterFactory.XML_TIME_ZONE, timeZone);
			}
			
			String datePattern = remoteXmlDataAdapter.getDatePattern();
			if (datePattern != null && datePattern.trim().length()>0) {
				parameters.put(JRXPathQueryExecuterFactory.XML_DATE_PATTERN, datePattern);
			}

			String numberPattern = remoteXmlDataAdapter.getNumberPattern();
			if (numberPattern != null && numberPattern.trim().length()>0) {
				parameters.put(JRXPathQueryExecuterFactory.XML_NUMBER_PATTERN, numberPattern);
			}
		}
	}
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:61,代码来源:RemoteXmlDataAdapterService.java

示例14: fillReport

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
public JasperPrint fillReport(ReportEngineInput input) throws ProviderException
{
    Connection conn = null;

    Report report = input.getReport();
    Map<String,Object> parameters = input.getParameters();

    ReportDataSource dataSource = report.getDataSource();

    try
    {
        JasperReport jr = null;

        if (report.isQueryReport()) return fillQueryReport(report, parameters, input.getExportType());

        jr = (JasperReport) JRLoader
                .loadObject(directoryProvider.getReportDirectory() + report.getFile());

        List<ReportParameterMap> subReports = report.getSubReportParameters();
        if (subReports != null && subReports.size() > 0)
        {
            Iterator<ReportParameterMap> iterator = report.getSubReportParameters().iterator();
            while (iterator.hasNext())
            {
                ReportParameterMap rpMap = iterator.next();

                JasperReport subReport = (JasperReport) JRLoader.loadObject(directoryProvider
                        .getReportDirectory()
                        + rpMap.getReportParameter().getData());

                parameters.put(rpMap.getReportParameter().getName(), subReport);
            }
        }

        JasperPrint jp = null;

        // create new HashMap to send to JasperReports in order to
        // fix serialization problems
        Map<String,Object> jasperReportMap = new HashMap<String,Object>(parameters);

        if (input.getXmlInput() != null)
        {
            ByteArrayInputStream stream = new ByteArrayInputStream(input.getXmlInput().getBytes());
            Document document = JRXmlUtils.parse(stream);

            jasperReportMap.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document);

            jp = JasperFillManager.fillReport(jr, jasperReportMap);
        }
        else if (dataSource == null)
        {
            jp = JasperFillManager.fillReport(jr, jasperReportMap, new JREmptyDataSource());
        }
        else
        {
            conn = dataSourceProvider.getConnection(dataSource.getId());
            jp = JasperFillManager.fillReport(jr, jasperReportMap, conn);
        }

        if (jp == null || jp.getPages().size() < 1) throw new ProviderException(LocalStrings.ERROR_REPORT_EMPTY);

        return jp;
    }
    catch (Exception e)
    {
        if (!e.getMessage().equals(LocalStrings.ERROR_REPORT_EMPTY)) log.error("JasperReportEngine.fillReport", e);
        throw new ProviderException(e.getMessage());
    }
    finally
    {
        try
        {
            if (conn != null) conn.close();
        }
        catch (Exception ex)
        {
            log.error("Error closing connection: " + ex.getMessage());
        }
    }
}
 
开发者ID:mtpettyp,项目名称:openreports,代码行数:81,代码来源:JasperReportEngine.java

示例15: createCheckBoxData

import net.sf.jasperreports.engine.util.JRXmlUtils; //导入方法依赖的package包/类
protected List<ServerProfile> createCheckBoxData(Properties prop) {
	List<ServerProfile> result = new ArrayList<ServerProfile>();
	String xmlString = prop.getProperty("serverprofiles");
	if (xmlString == null)
		return result;

	Document document;
	try {
		document = JRXmlUtils.parse(new InputSource(new StringReader(xmlString)));
		Node actualNode = document.getFirstChild();
		if (actualNode.hasChildNodes())
			actualNode = actualNode.getFirstChild();
		else
			actualNode = null;
		while (actualNode != null) {
			if (actualNode.getNodeName().equals("serverProfile")) {
				Node child = actualNode.getFirstChild();
				ServerProfile srv = new ServerProfile();
				while (child != null) {
					if (child.getNodeName().equals("name"))
						srv.setName(child.getTextContent());
					if (child.getNodeName().equals("jrVersion"))
						srv.setJrVersion(child.getTextContent());
					if (child.getNodeName().equals("url")) {
						String connectionString = child.getTextContent();
						if (connectionString.endsWith("/services/repository")) { //$NON-NLS-1$
							connectionString = connectionString.substring(0, connectionString.lastIndexOf("services/repository")); //$NON-NLS-1$
						}
						srv.setUrl(connectionString);
					}
					if (child.getNodeName().equals("user"))
						srv.setUser(child.getTextContent());
					if (child.getNodeName().equals("pass"))
						srv.setPass(child.getTextContent());
					if (child.getNodeName().equals("supportsDateRanges"))
						srv.setSupportsDateRanges(child.getTextContent().equals("true"));
					if (child.getNodeName().equals("chunked"))
						srv.setChunked(child.getTextContent().equals("true"));
					if (child.getNodeName().equals("timeout"))
						srv.setTimeout(Integer.parseInt(child.getTextContent()));
					child = child.getNextSibling();
				}
				result.add(srv);
			}
			actualNode = actualNode.getNextSibling();
		}
	} catch (JRException e) {
		e.printStackTrace();
	}
	return result;
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:52,代码来源:ImportJSSServersWizard.java


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