Package framework.utils

Examples of framework.utils.XMLData


*/
public class Parser {

    public static String xmlCheckupToUserView(String xml, String metadata) throws JDOMException {
        String target = "\n";
        XMLData data = new XMLData(xml, metadata);

        //название анализа
        //Фиелды до таблицы
        ArrayList<Pair<Integer, String>> preField = data.getPreFieldList();

        for(int i = 0; i < preField.size(); i++) {
            String fieldName = preField.get(i).second + ": ";
            String fieldValue = data.getField(preField.get(i).first);
            if (fieldValue == null || fieldValue.trim().isEmpty()) {
                continue;
            }
            target += fieldName + fieldValue + "\n";
        }

        ArrayList<String> probeList = data.getProbeList();
        if (!probeList.isEmpty()) {
            //добавляем заголовок таблицы
            ArrayList<String> valueList = data.getProbeValueList();

            //добавляем строки таблицы
            for (int i = 0; i < probeList.size(); i++) {
                if (!probeList.get(i).startsWith("separator")) {
                    String str = data.getProbeTitle(probeList.get(i)) + " ";
                    for (int j = 0; j < valueList.size(); j++) {
                        Object value = data.getProbeValue(probeList.get(i), valueList.get(j));
                        String metric = data.getProbeValueMetric(probeList.get(i), valueList.get(j));
                        String valueMetric = ( value == null ? "" : value.toString() + " " + (metric == null ? "" : metric));
                        if (value != null && !value.toString().trim().isEmpty()) {
                            str += valueMetric + ", ";
                        }
                    }
                    String strProbeNumber = "";
                    String probeNumber = data.getProbeNumber(probeList.get(i));
                    if (probeNumber != null) {
                        if (probeNumber.isEmpty()) {
                            strProbeNumber = " (Номер пробы не указан)";
                        } else {
                            strProbeNumber = " (Номер пробы " + probeNumber + ")";
                        }
                    }
                    if (!str.trim().isEmpty()) {
                        target += str + strProbeNumber + "\n";
                    }

                }
            }
        }
        //Фиелды после таблицы
        ArrayList<Pair<Integer, String>> postField = data.getPostFieldList();
        for(int i = 0; i < postField.size(); i++) {
            String fieldName = postField.get(i).second + ": ";
            String fieldValue = data.getField(postField.get(i).first);
            if (fieldValue == null || fieldValue.trim().isEmpty()) {
                continue;
            }
            target += fieldName + fieldValue + "\n";
        }
View Full Code Here

TOP

Related Classes of framework.utils.XMLData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.