Compare commits
15 commits
Author | SHA1 | Date | |
---|---|---|---|
5c2010a385 | |||
a4139a6dd2 | |||
bad7f6a1dd | |||
a38374d52b | |||
3e4bf56c2a | |||
1637db4144 | |||
2054640e06 | |||
2637f4e2c8 | |||
900f402000 | |||
1dfc9f0eb2 | |||
33a35fcf96 | |||
cd18cc99fa | |||
000b1091af | |||
2bd5823294 | |||
0fe7db58fb |
26 changed files with 466 additions and 55 deletions
17
.classpath
17
.classpath
|
@ -2,6 +2,12 @@
|
|||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="src" path="test"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||
<attributes>
|
||||
<attribute name="module" value="true"/>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
|
||||
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Logs/log4j-1.2.17-source.zip"/>
|
||||
|
@ -9,16 +15,11 @@
|
|||
<classpathentry kind="lib" path="lib/UnitTesting/hamcrest-core-1.3.jar" sourcepath="lib/UnitTesting/hamcrest-core-1.3-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/UnitTesting/fest-assert-1.4.jar"/>
|
||||
<classpathentry kind="lib" path="lib/UnitTesting/fest-util-1.1.6.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="owner.project.facets" value="java"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="lib" path="lib/UnitTesting/junit-4.12.jar" sourcepath="lib/UnitTesting/junit-4.12-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Logs/slf4j-api-1.7.25.jar" sourcepath="lib/Logs/slf4j-api-1.7.25-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Logs/slf4j-log4j12-1.7.25.jar" sourcepath="lib/Logs/slf4j-log4j12-1.7.25-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang3-3.7.jar" sourcepath="lib/commons-lang3-3.7-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/devinsy-strings-0.8.2.jar" sourcepath="lib/devinsy-strings-0.8.2-sources.zip"/>
|
||||
<classpathentry kind="lib" path="lib/devinsy-utils-0.8.0.jar" sourcepath="lib/devinsy-utils-0.8.0-sources.zip"/>
|
||||
<classpathentry kind="lib" path="lib/commons-text-1.9.jar" sourcepath="lib/commons-text-1.9-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-lang3-3.13.0.jar" sourcepath="lib/commons-lang3-3.13.0-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/devinsy-strings-0.17.0.jar" sourcepath="lib/devinsy-strings-0.17.0-sources.zip"/>
|
||||
<classpathentry kind="output" path="build/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -11,16 +11,20 @@ org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
|
|||
org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.compliance=11
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
||||
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=11
|
||||
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
|
||||
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||
|
@ -28,17 +32,20 @@ org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_c
|
|||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=49
|
||||
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||
|
@ -124,11 +131,12 @@ org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert
|
|||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert
|
||||
org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||
|
@ -159,6 +167,8 @@ org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
|||
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||
|
@ -183,13 +193,17 @@ org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
|||
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||
|
@ -237,6 +251,8 @@ org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do no
|
|||
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||
|
@ -273,9 +289,12 @@ org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not inser
|
|||
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||
|
@ -301,6 +320,10 @@ org.eclipse.jdt.core.formatter.tabulation.char=space
|
|||
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||
org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
|
||||
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
<fixed facet="jst.java"/>
|
||||
<fixed facet="jst.utility"/>
|
||||
<installed facet="jst.utility" version="1.0"/>
|
||||
<installed facet="jst.java" version="1.8"/>
|
||||
<installed facet="jst.java" version="11"/>
|
||||
</faceted-project>
|
||||
|
|
22
README.md
Normal file
22
README.md
Normal file
|
@ -0,0 +1,22 @@
|
|||
|
||||
# XIDYN
|
||||
|
||||
Xidyn provides an easy template solution.
|
||||
|
||||
## Author
|
||||
Christian Pierre MOMON <christian.momon@devinsy.fr>
|
||||
|
||||
## License
|
||||
This software is released under the GNU LGPL.
|
||||
|
||||
## Requirements
|
||||
|
||||
- Java 11
|
||||
- Eclipse 4.16 (202006).
|
||||
|
||||
## Context
|
||||
Several useful Java classes.
|
||||
|
||||
|
||||
## Conclusion
|
||||
Enjoy and use Xidyn. For questions, improvement, issues: christian.momon@devinsy.fr
|
|
@ -1,3 +1,3 @@
|
|||
#Build Number for ANT. Do not edit!
|
||||
#Sat Jan 18 17:09:30 CET 2020
|
||||
build.number=3
|
||||
#Mon Nov 27 12:47:18 CET 2023
|
||||
build.number=1
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
product.name=xidyn
|
||||
product.revision.major=1
|
||||
product.revision.minor=8
|
||||
product.revision.minor=17
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
This project is using the following libraries:
|
||||
|
||||
# Main requirements:
|
||||
devinsy-utils GNU LGPL useful tools (StringList…)
|
||||
commons-lang3 Apache 2
|
||||
|
||||
# Unit testing requirements:
|
||||
|
|
BIN
lib/commons-lang3-3.13.0-sources.jar
Normal file
BIN
lib/commons-lang3-3.13.0-sources.jar
Normal file
Binary file not shown.
BIN
lib/commons-lang3-3.13.0.jar
Normal file
BIN
lib/commons-lang3-3.13.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
lib/commons-text-1.9-sources.jar
Normal file
BIN
lib/commons-text-1.9-sources.jar
Normal file
Binary file not shown.
BIN
lib/commons-text-1.9.jar
Normal file
BIN
lib/commons-text-1.9.jar
Normal file
Binary file not shown.
BIN
lib/devinsy-strings-0.17.0-sources.zip
Normal file
BIN
lib/devinsy-strings-0.17.0-sources.zip
Normal file
Binary file not shown.
BIN
lib/devinsy-strings-0.17.0.jar
Normal file
BIN
lib/devinsy-strings-0.17.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -21,6 +21,7 @@ package fr.devinsy.xidyn.data;
|
|||
import java.io.Serializable;
|
||||
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
import fr.devinsy.xidyn.utils.XidynUtils;
|
||||
|
||||
/**
|
||||
* The Class SimpleTagData.
|
||||
|
@ -49,7 +50,7 @@ public class SimpleTagData implements Serializable, TagData
|
|||
ALL_ROWS
|
||||
}
|
||||
|
||||
IterationStrategy iterationStrategy;
|
||||
private IterationStrategy iterationStrategy;
|
||||
private TagAttributes attributes;
|
||||
private boolean excludeSection;
|
||||
private DisplayMode displayMode = DisplayMode.REPLACE;
|
||||
|
@ -344,6 +345,30 @@ public class SimpleTagData implements Serializable, TagData
|
|||
this.displayMode = displayMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped attribute.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setEscapedAttribute(final String label, final String value)
|
||||
{
|
||||
setAttribute(label, XidynUtils.escapeXmlBlank(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped content.
|
||||
*
|
||||
* @param text
|
||||
* the new escaped content
|
||||
*/
|
||||
public void setEscapedContent(final String text)
|
||||
{
|
||||
setContent(XidynUtils.escapeXmlBlank(text));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the exclude section.
|
||||
*
|
||||
|
|
|
@ -659,6 +659,114 @@ public class TagDataManager
|
|||
idData.setContent(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped attribute.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setEscapedAttribute(final String id, final int line, final String label, final String value)
|
||||
{
|
||||
SimpleTagData tag = this.getIdData(id, line);
|
||||
|
||||
tag.setEscapedAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped attribute.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param column
|
||||
* the column
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setEscapedAttribute(final String id, final int line, final String column, final String label, final String value)
|
||||
{
|
||||
SimpleTagData tag = this.getIdData(id, line, column);
|
||||
|
||||
tag.setEscapedAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped attribute.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setEscapedAttribute(final String id, final String label, final String value)
|
||||
{
|
||||
SimpleTagData tag = this.getIdData(id);
|
||||
|
||||
tag.setEscapedAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped content.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param content
|
||||
* the content
|
||||
*/
|
||||
public void setEscapedContent(final String id, final int line, final String content)
|
||||
{
|
||||
SimpleTagData tag = this.getIdData(id, line);
|
||||
|
||||
tag.setEscapedContent(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped content.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param column
|
||||
* the column
|
||||
* @param content
|
||||
* the content
|
||||
*/
|
||||
public void setEscapedContent(final String id, final int line, final String column, final String content)
|
||||
{
|
||||
SimpleTagData tag = this.getIdData(id, line, column);
|
||||
|
||||
tag.setEscapedContent(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the escaped content.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param content
|
||||
* the content
|
||||
*/
|
||||
public void setEscapedContent(final String id, final String content)
|
||||
{
|
||||
SimpleTagData idData = this.getIdData(id);
|
||||
|
||||
idData.setEscapedContent(content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the iteration strategy.
|
||||
*
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import fr.devinsy.util.FileTools;
|
||||
import fr.devinsy.xidyn.utils.XidynUtils;
|
||||
import fr.devinsy.xidyn.utils.cache.Cache;
|
||||
|
||||
/**
|
||||
|
@ -35,8 +35,6 @@ import fr.devinsy.xidyn.utils.cache.Cache;
|
|||
*/
|
||||
public class PresenterFactory
|
||||
{
|
||||
private static Logger logger = LoggerFactory.getLogger(PresenterFactory.class);
|
||||
|
||||
/**
|
||||
* http://thecodersbreakfast.net/index.php?post/2008/02/25/26-de-la-bonne-
|
||||
* implementation-du-singleton-en-java
|
||||
|
@ -46,6 +44,8 @@ public class PresenterFactory
|
|||
private final static PresenterFactory INSTANCE = new PresenterFactory();
|
||||
}
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(PresenterFactory.class);
|
||||
|
||||
private Cache<Presenter> cache;
|
||||
|
||||
/**
|
||||
|
@ -110,7 +110,7 @@ public class PresenterFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
String localizedSource = FileTools.addBeforeExtension(source.toString(), "-" + locale.getLanguage());
|
||||
String localizedSource = XidynUtils.insertBeforeExtension(source.toString(), "-" + locale.getLanguage());
|
||||
|
||||
result = this.cache.get(localizedSource);
|
||||
|
||||
|
@ -200,7 +200,7 @@ public class PresenterFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
File localizedSource = new File(FileTools.addBeforeExtension(source.getAbsolutePath(), "-" + locale.getLanguage()));
|
||||
File localizedSource = new File(XidynUtils.insertBeforeExtension(source.getAbsolutePath(), "-" + locale.getLanguage()));
|
||||
|
||||
result = this.cache.get(localizedSource);
|
||||
|
||||
|
@ -271,7 +271,7 @@ public class PresenterFactory
|
|||
{
|
||||
URL localizedSource;
|
||||
|
||||
localizedSource = new URL(FileTools.addBeforeExtension(source.getPath(), "-" + locale.getLanguage()));
|
||||
localizedSource = new URL(XidynUtils.insertBeforeExtension(source.getPath(), "-" + locale.getLanguage()));
|
||||
|
||||
result = this.cache.get(localizedSource);
|
||||
|
||||
|
@ -383,7 +383,7 @@ public class PresenterFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
String localizedSource = FileTools.addBeforeExtension(source.toString(), "-" + locale.getLanguage());
|
||||
String localizedSource = XidynUtils.insertBeforeExtension(source.toString(), "-" + locale.getLanguage());
|
||||
|
||||
result = create(localizedSource);
|
||||
|
||||
|
@ -468,7 +468,7 @@ public class PresenterFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
File localizedSource = new File(FileTools.addBeforeExtension(source.getAbsolutePath(), "-" + locale.getLanguage()));
|
||||
File localizedSource = new File(XidynUtils.insertBeforeExtension(source.getAbsolutePath(), "-" + locale.getLanguage()));
|
||||
|
||||
result = create(localizedSource);
|
||||
|
||||
|
@ -531,7 +531,7 @@ public class PresenterFactory
|
|||
}
|
||||
else
|
||||
{
|
||||
URL localizedSource = new URL(FileTools.addBeforeExtension(source.getPath(), "-" + locale.getLanguage()));
|
||||
URL localizedSource = new URL(XidynUtils.insertBeforeExtension(source.getPath(), "-" + locale.getLanguage()));
|
||||
|
||||
result = create(localizedSource);
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ import java.util.HashMap;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import fr.devinsy.util.FileTools;
|
||||
import fr.devinsy.xidyn.XidynException;
|
||||
import fr.devinsy.xidyn.data.TagDataManager;
|
||||
import fr.devinsy.xidyn.utils.XidynUtils;
|
||||
|
||||
/**
|
||||
* The Class TranslatorPresenter.
|
||||
|
@ -270,7 +270,7 @@ public class TranslatorPresenter implements Presenter
|
|||
}
|
||||
else
|
||||
{
|
||||
String adaptedSource = FileTools.addBeforeExtension(this.defaultSource, "-" + language);
|
||||
String adaptedSource = XidynUtils.insertBeforeExtension(this.defaultSource, "-" + language);
|
||||
result = PresenterFactory.create(adaptedSource);
|
||||
|
||||
if (result.isAvailable())
|
||||
|
@ -279,7 +279,7 @@ public class TranslatorPresenter implements Presenter
|
|||
}
|
||||
else
|
||||
{
|
||||
adaptedSource = FileTools.addBeforeExtension(this.defaultSource, "_" + language);
|
||||
adaptedSource = XidynUtils.insertBeforeExtension(this.defaultSource, "_" + language);
|
||||
|
||||
if (result.isAvailable())
|
||||
{
|
||||
|
|
|
@ -34,6 +34,8 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
|||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.validation.Schema;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
@ -131,7 +133,8 @@ public class XidynUtils
|
|||
if (errorHandler.hasError())
|
||||
{
|
||||
// Most time, error is (with StringPresenter):
|
||||
// "Error at line 1 : Document root element "html", must match DOCTYPE root
|
||||
// "Error at line 1 : Document root element "html", must match
|
||||
// DOCTYPE root
|
||||
// "null".
|
||||
// Error at line 1 : Document is invalid: no grammar found.
|
||||
// We ignore it. STU
|
||||
|
@ -210,7 +213,8 @@ public class XidynUtils
|
|||
if (errorHandler.hasError())
|
||||
{
|
||||
// Most time, error is (with StringPresenter):
|
||||
// "Error at line 1 : Document root element "html", must match DOCTYPE root
|
||||
// "Error at line 1 : Document root element "html", must match
|
||||
// DOCTYPE root
|
||||
// "null".
|
||||
// Error at line 1 : Document is invalid: no grammar found.
|
||||
// We ignore it. STU
|
||||
|
@ -243,6 +247,30 @@ public class XidynUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape xml blank.
|
||||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @return the string
|
||||
*/
|
||||
public static String escapeXmlBlank(final String source)
|
||||
{
|
||||
String result;
|
||||
|
||||
if (StringUtils.isBlank(source))
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = StringEscapeUtils.escapeXml11(source);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Good estimation of the target length able to optimize performance.
|
||||
*
|
||||
|
@ -315,11 +343,12 @@ public class XidynUtils
|
|||
/**
|
||||
* This method extracts the string before the <i>html</i> tag.
|
||||
*
|
||||
* A possible way is to use pattern searching for <i>$(.*)<html>.*^</i>.
|
||||
* But if there is no <i>html</i> tag, all the source is read for nothing.
|
||||
* A possible way is to use pattern searching for
|
||||
* <i>$(.*)<html>.*^</i>. But if there is no <i>html</i> tag, all the
|
||||
* source is read for nothing.
|
||||
*
|
||||
* A best way is to analyze each < while it is a XML tag or a DOCTYPE tag or
|
||||
* the <HTML> tag.
|
||||
* A best way is to analyze each < while it is a XML tag or a DOCTYPE tag
|
||||
* or the <HTML> tag.
|
||||
*
|
||||
* Uses cases:
|
||||
*
|
||||
|
@ -330,8 +359,8 @@ public class XidynUtils
|
|||
*
|
||||
* @param source
|
||||
* the source
|
||||
* @return the string before the <i>html</i> tag or null if no <i>html</i> tag
|
||||
* found. So, "" if there is a <i>html</i> tag without doctype.
|
||||
* @return the string before the <i>html</i> tag or null if no <i>html</i>
|
||||
* tag found. So, "" if there is a <i>html</i> tag without doctype.
|
||||
*/
|
||||
public static String extractDoctype(final String source)
|
||||
{
|
||||
|
@ -568,6 +597,45 @@ public class XidynUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert before extension.
|
||||
*
|
||||
* @param fileName
|
||||
* the file name
|
||||
* @param addition
|
||||
* the addition
|
||||
* @return the string
|
||||
*/
|
||||
public static String insertBeforeExtension(final String fileName, final String addition)
|
||||
{
|
||||
String result;
|
||||
|
||||
if (fileName == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else if (addition == null)
|
||||
{
|
||||
result = fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
int separatorIndex = fileName.lastIndexOf('.');
|
||||
|
||||
if (separatorIndex > 0)
|
||||
{
|
||||
result = fileName.substring(0, separatorIndex) + addition + fileName.substring(separatorIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = fileName + addition;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load.
|
||||
*
|
||||
|
@ -788,8 +856,8 @@ public class XidynUtils
|
|||
}
|
||||
|
||||
/**
|
||||
* Any ampersand lt;, ampersand gt; and ampersand amp; sequences in text nodes
|
||||
* get read in as symbols. This method converts them back to entities.
|
||||
* Any ampersand lt;, ampersand gt; and ampersand amp; sequences in text
|
||||
* nodes get read in as symbols. This method converts them back to entities.
|
||||
*
|
||||
* @param source
|
||||
* String that is to have the entities restored..
|
||||
|
|
|
@ -255,4 +255,25 @@ public class TagDataManagerTest
|
|||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test set escaped content.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void testSetEscapedContent01() throws Exception
|
||||
{
|
||||
String source = "<span id='foo'>n/a</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setEscapedContent("foo", "<b>foo</b>");
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span id=\"foo\"><b>foo</b></span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2017 Christian Pierre MOMON
|
||||
* Copyright (C) 2006-2023 Christian Pierre MOMON <christian@momon.org>
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
|
@ -21,7 +21,7 @@ package fr.devinsy.xidyn.utils;
|
|||
import org.apache.log4j.BasicConfigurator;
|
||||
import org.apache.log4j.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.fest.assertions.Assertions;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class XidynUtilsTest
|
|||
String source = "aaaaa<boDY>hello</Body>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractBodyContent(source);
|
||||
Assertions.assertThat(target).isEqualTo("hello");
|
||||
Assert.assertEquals(target, "hello");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ public class XidynUtilsTest
|
|||
String source = "aaaaaaa<boDY>hello</Bod>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractBodyContent(source);
|
||||
Assertions.assertThat(target).isEqualTo("");
|
||||
Assert.assertEquals(target, "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ public class XidynUtilsTest
|
|||
String source = "aaaaa<body></BodY>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractBodyContent(source);
|
||||
Assertions.assertThat(target).isEqualTo("");
|
||||
Assert.assertEquals(target, "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +85,7 @@ public class XidynUtilsTest
|
|||
String source = "aaaaa<boDY> hello </body>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractBodyContent(source);
|
||||
Assertions.assertThat(target).isEqualTo("hello");
|
||||
Assert.assertEquals(target, "hello");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ public class XidynUtilsTest
|
|||
|
||||
// System.out.println("[" + source + "]");
|
||||
String target = XidynUtils.extractBodyContent(source);
|
||||
Assertions.assertThat(target).isEqualTo("WELCOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOME");
|
||||
Assert.assertEquals(target, "WELCOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOME");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ public class XidynUtilsTest
|
|||
String source = "aaaaa<boDY>hello</Body>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractDoctype(source);
|
||||
Assertions.assertThat(target).isNull();
|
||||
Assert.assertNull(target);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +138,7 @@ public class XidynUtilsTest
|
|||
String source = "<html xmlns='http://www.w3.org/1999/xhtml'>aaaaa<boDY>hello</Body>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractDoctype(source);
|
||||
Assertions.assertThat(target).isEqualTo("");
|
||||
Assert.assertEquals(target, "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ public class XidynUtilsTest
|
|||
String source = "<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'>aaaaa<boDY>hello</Body>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractDoctype(source);
|
||||
Assertions.assertThat(target).isEqualTo("<!DOCTYPE html>");
|
||||
Assert.assertEquals(target, "<!DOCTYPE html>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,7 +162,7 @@ public class XidynUtilsTest
|
|||
String source = "<?xml version='1.0' encoding='UTF-8' ?><!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'>aaaaa<boDY>hello</Body>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractDoctype(source);
|
||||
Assertions.assertThat(target).isEqualTo("<?xml version='1.0' encoding='UTF-8' ?><!DOCTYPE html>");
|
||||
Assert.assertEquals(target, "<?xml version='1.0' encoding='UTF-8' ?><!DOCTYPE html>");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,6 +174,150 @@ public class XidynUtilsTest
|
|||
String source = "<?xml version='1.0' encoding='UTF-8' ?><!-- TOTOT --><!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'>aaaaa<boDY>hello</Body>zzzzz";
|
||||
|
||||
String target = XidynUtils.extractDoctype(source);
|
||||
Assertions.assertThat(target).isEqualTo("<?xml version='1.0' encoding='UTF-8' ?><!-- TOTOT --><!DOCTYPE html>");
|
||||
Assert.assertEquals(target, "<?xml version='1.0' encoding='UTF-8' ?><!-- TOTOT --><!DOCTYPE html>");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 01.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension01()
|
||||
{
|
||||
String source = null;
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, null);
|
||||
Assert.assertNull(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 02.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension02()
|
||||
{
|
||||
String source = null;
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "");
|
||||
Assert.assertNull(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 03.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension03()
|
||||
{
|
||||
String source = null;
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "-fr");
|
||||
Assert.assertNull(target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 05.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension05()
|
||||
{
|
||||
String source = "";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, null);
|
||||
Assert.assertEquals(target, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 06.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension06()
|
||||
{
|
||||
String source = "";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "");
|
||||
Assert.assertEquals(target, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 07.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension07()
|
||||
{
|
||||
String source = "";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "-fr");
|
||||
Assert.assertEquals(target, "-fr");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 08.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension08()
|
||||
{
|
||||
String source = "foo";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, null);
|
||||
Assert.assertEquals(target, "foo");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 09.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension09()
|
||||
{
|
||||
String source = "foo";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "");
|
||||
Assert.assertEquals(target, "foo");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 10.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension10()
|
||||
{
|
||||
String source = "foo";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "-fr");
|
||||
Assert.assertEquals(target, "foo-fr");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 11.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension11()
|
||||
{
|
||||
String source = "foo.txt";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, null);
|
||||
Assert.assertEquals(target, "foo.txt");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 12.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension12()
|
||||
{
|
||||
String source = "foo.txt";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "");
|
||||
Assert.assertEquals(target, "foo.txt");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test insert before extension 13.
|
||||
*/
|
||||
@Test
|
||||
public void testInsertBeforeExtension13()
|
||||
{
|
||||
String source = "foo.txt";
|
||||
|
||||
String target = XidynUtils.insertBeforeExtension(source, "-fr");
|
||||
Assert.assertEquals(target, "foo-fr.txt");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue