use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project maven-release by apache.
the class JDomModelTest method testSetScm.
@Test
public void testSetScm() throws Exception {
String content = "<project></project>";
Document document = builder.build(new StringReader(content));
Model model = new JDomModel(document);
assertNull(model.getScm());
model.setScm(new Scm());
assertNotNull(model.getScm());
model.setScm(null);
assertNull(model.getScm());
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project maven-release by apache.
the class JDomModelTest method testGetScm.
@Test
public void testGetScm() throws Exception {
String content = "<project></project>";
Document document = builder.build(new StringReader(content));
assertNull(new JDomModel(document).getScm());
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project ApkToolBoxGUI by jiangxincode.
the class I18nAddPanel method getSourceElement.
private Element getSourceElement(File sourceFile, String itemName) {
if (!sourceFile.exists()) {
logger.warn("sourceFile does not exist: " + sourceFile);
return null;
}
SAXBuilder builder = new SAXBuilder();
Document sourceDoc = null;
try (InputStream in = new FileInputStream(sourceFile)) {
sourceDoc = builder.build(in);
logger.info("build source document: " + sourceFile);
} catch (JDOMException | IOException e) {
logger.error("build source document failed: " + sourceFile, e);
return null;
}
if (sourceDoc == null) {
logger.error("sourceDoc is null");
return null;
}
Element sourceElement = null;
for (Element sourceChild : sourceDoc.getRootElement().getChildren()) {
String sourceValue = sourceChild.getAttributeValue("name");
if (sourceValue != null && sourceValue.equals(itemName)) {
sourceElement = sourceChild.clone();
break;
}
}
return sourceElement;
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project ApkToolBoxGUI by jiangxincode.
the class I18nAddPanel method setTargetElement.
private boolean setTargetElement(File targetFile, Element sourceElement, String itemName) {
SAXBuilder builder = new SAXBuilder();
Document targetDoc;
try {
targetDoc = builder.build(targetFile);
logger.info("build target document: " + targetFile);
} catch (JDOMException | IOException e) {
logger.error("build target document failed: " + targetFile, e);
return false;
}
Element targetRoot = targetDoc.getRootElement();
boolean isFinished = false;
for (Element targetChild : targetRoot.getChildren()) {
String targetValue = targetChild.getAttributeValue("name");
if (targetValue != null && targetValue.equals(itemName)) {
targetChild.setText(sourceElement.getText());
isFinished = true;
break;
}
}
if (!isFinished) {
targetRoot.addContent(" ");
targetRoot.addContent(sourceElement);
targetRoot.addContent("\n");
}
XMLOutputter out = new XMLOutputter();
Format format = Format.getRawFormat();
format.setEncoding("UTF-8");
format.setLineSeparator("\n");
out.setFormat(format);
OutputStream os = null;
try {
os = new FileOutputStream(targetFile);
out.output(targetDoc, os);
} catch (IOException e) {
logger.error("output fail", e);
return false;
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
logger.error("close output stream exception", e);
}
}
}
return true;
}
use of com.forgerock.openbanking.common.model.openbanking.obie.pain00200109.Document in project ApkToolBoxGUI by jiangxincode.
the class I18nInfo method sort.
private void sort(String sourceBaseStr, String itemName) {
File[] sourceParentFiles = new File(sourceBaseStr).listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return pathname.getName().startsWith("values");
}
});
if (sourceParentFiles == null) {
logger.error("None valid directory found");
return;
}
for (File sourceParentFile : sourceParentFiles) {
File sourceFile = new File(sourceParentFile, "strings.xml");
if (sourceFile.exists()) {
SAXBuilder builder = new SAXBuilder();
Document sourceDoc;
try {
sourceDoc = builder.build(sourceFile);
} catch (JDOMException | IOException e) {
logger.error("build failed: " + sourceFile, e);
continue;
}
Element sourceRoot = sourceDoc.getRootElement();
for (Element child : sourceRoot.getChildren()) {
String value = child.getAttributeValue("name");
if (value != null && value.equals(itemName)) {
String text = child.getText();
if (text != null) {
I18nInfo info = new I18nInfo(getCanonicalPath(sourceFile), text, text.length());
infos.add(info);
break;
}
}
}
}
}
Collections.sort(infos, new Comparator<I18nInfo>() {
@Override
public int compare(I18nInfo o1, I18nInfo o2) {
return o2.length - o1.length;
}
});
logger.info(infos);
}
Aggregations