Compare commits
25 commits
Author | SHA1 | Date | |
---|---|---|---|
5c2010a385 | |||
a4139a6dd2 | |||
bad7f6a1dd | |||
a38374d52b | |||
3e4bf56c2a | |||
1637db4144 | |||
2054640e06 | |||
2637f4e2c8 | |||
900f402000 | |||
1dfc9f0eb2 | |||
33a35fcf96 | |||
cd18cc99fa | |||
000b1091af | |||
2bd5823294 | |||
0fe7db58fb | |||
25146963ff | |||
047acd4ef3 | |||
f360eb89f4 | |||
fb8cd7beef | |||
66b394cb32 | |||
3ab9909181 | |||
ad51edcb07 | |||
5b62d85bf0 | |||
bdf194db05 | |||
1e0e702a66 |
32 changed files with 1281 additions and 408 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!
|
||||
#Mon Oct 03 06:15:00 CEST 2016
|
||||
build.number=0
|
||||
#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.
29
src/fr/devinsy/xidyn/data/DisplayMode.java
Normal file
29
src/fr/devinsy/xidyn/data/DisplayMode.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2017,2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
* Xidyn is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Xidyn is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Xidyn. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package fr.devinsy.xidyn.data;
|
||||
|
||||
/**
|
||||
* The Enum DisplayMode.
|
||||
*/
|
||||
public enum DisplayMode
|
||||
{
|
||||
REPLACE,
|
||||
APPEND,
|
||||
IGNORE
|
||||
};
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2017 Christian Pierre MOMON
|
||||
* Copyright (C) 2006-2017,2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
|
@ -20,6 +20,9 @@ package fr.devinsy.xidyn.data;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import fr.devinsy.strings.StringsUtils;
|
||||
import fr.devinsy.xidyn.utils.XidynUtils;
|
||||
|
||||
/**
|
||||
* The Class SimpleTagData.
|
||||
*
|
||||
|
@ -36,6 +39,8 @@ import java.io.Serializable;
|
|||
*/
|
||||
public class SimpleTagData implements Serializable, TagData
|
||||
{
|
||||
private static final long serialVersionUID = 8976245034682639923L;
|
||||
|
||||
public enum IterationStrategy
|
||||
{
|
||||
ONLY_FIRST_ROW,
|
||||
|
@ -45,19 +50,10 @@ public class SimpleTagData implements Serializable, TagData
|
|||
ALL_ROWS
|
||||
}
|
||||
|
||||
public enum MODE
|
||||
{
|
||||
REPLACE,
|
||||
APPEND,
|
||||
IGNORE
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 8976245034682639923L;;
|
||||
|
||||
private IterationStrategy iterationStrategy;
|
||||
private TagAttributes attributes;
|
||||
private boolean excludeSection;
|
||||
private MODE displayMode = MODE.REPLACE;
|
||||
private DisplayMode displayMode = DisplayMode.REPLACE;
|
||||
private String content;
|
||||
|
||||
/**
|
||||
|
@ -65,11 +61,7 @@ public class SimpleTagData implements Serializable, TagData
|
|||
*/
|
||||
public SimpleTagData()
|
||||
{
|
||||
this.attributes = null;
|
||||
this.excludeSection = false;
|
||||
this.displayMode = MODE.REPLACE;
|
||||
this.content = null;
|
||||
this.iterationStrategy = IterationStrategy.ALL_ROWS;
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,13 +72,26 @@ public class SimpleTagData implements Serializable, TagData
|
|||
*/
|
||||
public SimpleTagData(final String text)
|
||||
{
|
||||
this.attributes = null;
|
||||
this.attributes = new TagAttributes();
|
||||
this.excludeSection = false;
|
||||
this.displayMode = MODE.REPLACE;
|
||||
this.displayMode = DisplayMode.REPLACE;
|
||||
this.content = text;
|
||||
this.iterationStrategy = IterationStrategy.ALL_ROWS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append attribute.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void appendAttribute(final String label, final String value)
|
||||
{
|
||||
this.attributes.appendAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append content.
|
||||
*
|
||||
|
@ -114,40 +119,20 @@ public class SimpleTagData implements Serializable, TagData
|
|||
{
|
||||
TagAttributes result;
|
||||
|
||||
if (this.attributes == null)
|
||||
{
|
||||
this.attributes = new TagAttributes();
|
||||
}
|
||||
|
||||
result = this.attributes;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String display()
|
||||
{
|
||||
String result;
|
||||
|
||||
result = this.content;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display mode.
|
||||
*
|
||||
* @return the mode
|
||||
*/
|
||||
public MODE displayMode()
|
||||
public DisplayMode displayMode()
|
||||
{
|
||||
MODE result;
|
||||
DisplayMode result;
|
||||
|
||||
result = this.displayMode;
|
||||
|
||||
|
@ -169,6 +154,88 @@ public class SimpleTagData implements Serializable, TagData
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @return the attribute
|
||||
*/
|
||||
public TagAttribute getAttribute(final String label)
|
||||
{
|
||||
TagAttribute result;
|
||||
|
||||
result = this.attributes.getAttribute(label);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute mode.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @return the attribute mode
|
||||
*/
|
||||
public DisplayMode getAttributeMode(final String label)
|
||||
{
|
||||
DisplayMode result;
|
||||
|
||||
TagAttribute attribute = this.attributes.get(label);
|
||||
if (attribute == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = attribute.getMode();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the attribute value.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @return the attribute value
|
||||
*/
|
||||
public String getAttributeValue(final String label)
|
||||
{
|
||||
String result;
|
||||
|
||||
TagAttribute attribute = this.attributes.get(label);
|
||||
if (attribute == null)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = attribute.getValue();
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
public String getContent()
|
||||
{
|
||||
String result;
|
||||
|
||||
result = this.content;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Iteration strategy.
|
||||
*
|
||||
|
@ -184,6 +251,78 @@ public class SimpleTagData implements Serializable, TagData
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void setAttribute(final String label, final String value)
|
||||
{
|
||||
if (this.attributes.containsKey(label))
|
||||
{
|
||||
this.attributes.get(label).setValue(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (StringsUtils.containsAnyIgnoreCase(label, "style", "class"))
|
||||
{
|
||||
this.attributes.put(label, new TagAttribute(label, value, DisplayMode.APPEND));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.attributes.put(label, new TagAttribute(label, value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
* @param mode
|
||||
* the mode
|
||||
*/
|
||||
public void setAttribute(final String label, final String value, final DisplayMode mode)
|
||||
{
|
||||
if (this.attributes.containsKey(label))
|
||||
{
|
||||
TagAttribute attribute = this.attributes.get(label);
|
||||
attribute.setValue(value);
|
||||
attribute.setMode(mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.attributes.put(label, new TagAttribute(label, value, mode));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute mode.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param mode
|
||||
* the mode
|
||||
*/
|
||||
public void setAttributeMode(final String label, final DisplayMode mode)
|
||||
{
|
||||
if (this.attributes.containsKey(label))
|
||||
{
|
||||
this.attributes.get(label).setMode(mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
TagAttribute tag = new TagAttribute(label, null, mode);
|
||||
this.attributes.put(label, tag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the content.
|
||||
*
|
||||
|
@ -201,11 +340,35 @@ public class SimpleTagData implements Serializable, TagData
|
|||
* @param displayMode
|
||||
* the new display mode
|
||||
*/
|
||||
public void setDisplayMode(final MODE displayMode)
|
||||
public void setDisplayMode(final DisplayMode displayMode)
|
||||
{
|
||||
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.
|
||||
*
|
||||
|
|
113
src/fr/devinsy/xidyn/data/TagAttribute.java
Normal file
113
src/fr/devinsy/xidyn/data/TagAttribute.java
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
* Xidyn is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Xidyn is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Xidyn. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package fr.devinsy.xidyn.data;
|
||||
|
||||
/**
|
||||
* The Class TagAttribute.
|
||||
*/
|
||||
public class TagAttribute
|
||||
{
|
||||
private DisplayMode mode;
|
||||
private String label;
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* Instantiates a new tag attribute.
|
||||
*
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public TagAttribute(final String label, final String value)
|
||||
{
|
||||
this(label, value, DisplayMode.REPLACE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new tag attribute.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
* @param mode
|
||||
* the mode
|
||||
*/
|
||||
public TagAttribute(final String label, final String value, final DisplayMode mode)
|
||||
{
|
||||
this.mode = mode;
|
||||
this.label = label;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append value.
|
||||
*
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void appendValue(final String value)
|
||||
{
|
||||
if (this.value == null)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.value = this.value + " " + value;
|
||||
}
|
||||
}
|
||||
|
||||
public String getLabel()
|
||||
{
|
||||
return this.label;
|
||||
}
|
||||
|
||||
public DisplayMode getMode()
|
||||
{
|
||||
return this.mode;
|
||||
}
|
||||
|
||||
public String getValue()
|
||||
{
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mode.
|
||||
*
|
||||
* @param mode
|
||||
* the new mode
|
||||
*/
|
||||
public void setMode(final DisplayMode mode)
|
||||
{
|
||||
if (mode == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Null parameter.");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mode = mode;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(final String value)
|
||||
{
|
||||
this.value = value;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2017 Christian Pierre MOMON
|
||||
* Copyright (C) 2006-2017,2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
|
@ -19,6 +19,7 @@
|
|||
package fr.devinsy.xidyn.data;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* The Class TagAttributes.
|
||||
|
@ -26,8 +27,7 @@ import java.util.HashMap;
|
|||
* Note: no more AttrValue as in Brill, because the exception of style is
|
||||
* managed in the attribute merging on the "style" string detection.
|
||||
*/
|
||||
|
||||
public class TagAttributes extends HashMap<String, String>
|
||||
public class TagAttributes extends HashMap<String, TagAttribute> implements Iterable<TagAttribute>
|
||||
{
|
||||
private static final long serialVersionUID = 2802739066295665336L;
|
||||
|
||||
|
@ -62,11 +62,11 @@ public class TagAttributes extends HashMap<String, String>
|
|||
{
|
||||
if (this.containsKey(label))
|
||||
{
|
||||
this.put(label, this.get(label) + " " + value);
|
||||
this.get(label).appendValue(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.put(label, value);
|
||||
this.put(label, new TagAttribute(label, value));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,9 +77,9 @@ public class TagAttributes extends HashMap<String, String>
|
|||
* the label
|
||||
* @return the attribute
|
||||
*/
|
||||
public String getAttribute(final String label)
|
||||
public TagAttribute getAttribute(final String label)
|
||||
{
|
||||
String result;
|
||||
TagAttribute result;
|
||||
|
||||
if (this.containsKey(label))
|
||||
{
|
||||
|
@ -95,15 +95,18 @@ public class TagAttributes extends HashMap<String, String>
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the attribute.
|
||||
* Iterator.
|
||||
*
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
* @return the iterator
|
||||
*/
|
||||
public void setAttribute(final String label, final String value)
|
||||
@Override
|
||||
public Iterator<TagAttribute> iterator()
|
||||
{
|
||||
this.put(label, value);
|
||||
Iterator<TagAttribute> result;
|
||||
|
||||
result = this.values().iterator();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2017 Christian Pierre MOMON
|
||||
* Copyright (C) 2006-2017,2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
|
@ -74,6 +74,82 @@ public class TagDataManager
|
|||
tags.add(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append attribute.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void appendAttribute(final String id, final int line, final String label, final long value)
|
||||
{
|
||||
appendAttribute(id, line, label, String.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append attribute.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void appendAttribute(final String id, final int line, final String label, final String value)
|
||||
{
|
||||
SimpleTagData tag = this.getIdData(id, line);
|
||||
|
||||
tag.attributes().appendAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append attribute.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param column
|
||||
* the column
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void appendAttribute(final String id, final int line, final String column, final String label, final long value)
|
||||
{
|
||||
appendAttribute(id, line, column, label, String.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append attribute.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param line
|
||||
* the line
|
||||
* @param column
|
||||
* the column
|
||||
* @param label
|
||||
* the label
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void appendAttribute(final String id, final int line, final String column, final String label, final String value)
|
||||
{
|
||||
SimpleTagData tag = this.getIdData(id, line, column);
|
||||
|
||||
tag.attributes().appendAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append attribute.
|
||||
*
|
||||
|
@ -174,6 +250,19 @@ public class TagDataManager
|
|||
tag.appendContent(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Append content.
|
||||
*
|
||||
* @param id
|
||||
* the id
|
||||
* @param value
|
||||
* the value
|
||||
*/
|
||||
public void appendContent(final String id, final long value)
|
||||
{
|
||||
appendContent(id, String.valueOf(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Append content.
|
||||
*
|
||||
|
@ -204,9 +293,8 @@ public class TagDataManager
|
|||
|
||||
if (result == null)
|
||||
{
|
||||
this.idsDataById.setId(id, new SimpleTagData());
|
||||
|
||||
result = (SimpleTagData) this.idsDataById.getId(id);
|
||||
result = new SimpleTagData();
|
||||
this.idsDataById.setId(id, result);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -230,9 +318,8 @@ public class TagDataManager
|
|||
TagDataListByIndex tags = (TagDataListByIndex) this.idsDataById.getId(id);
|
||||
if (tags == null)
|
||||
{
|
||||
this.idsDataById.setId(id, new TagDataListByIndex());
|
||||
|
||||
tags = (TagDataListByIndex) this.idsDataById.getId(id);
|
||||
tags = new TagDataListByIndex();
|
||||
this.idsDataById.setId(id, tags);
|
||||
}
|
||||
|
||||
// Be sure that lines are existing.
|
||||
|
@ -268,9 +355,8 @@ public class TagDataManager
|
|||
TagDataListByIndex tags = (TagDataListByIndex) this.idsDataById.getId(id);
|
||||
if (tags == null)
|
||||
{
|
||||
this.idsDataById.setId(id, new TagDataListByIndex());
|
||||
|
||||
tags = (TagDataListByIndex) this.idsDataById.getId(id);
|
||||
tags = new TagDataListByIndex();
|
||||
this.idsDataById.setId(id, tags);
|
||||
}
|
||||
|
||||
// Be sure that lines are existing.
|
||||
|
@ -287,9 +373,8 @@ public class TagDataManager
|
|||
|
||||
if (result == null)
|
||||
{
|
||||
lineData.put(column, new SimpleTagData());
|
||||
|
||||
result = (SimpleTagData) lineData.get(column);
|
||||
result = new SimpleTagData();
|
||||
lineData.put(column, result);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -297,11 +382,11 @@ public class TagDataManager
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the ids data by id.
|
||||
*
|
||||
* @return the ids data by id
|
||||
* Gets the root ids data.
|
||||
*
|
||||
* @return the root
|
||||
*/
|
||||
public TagDataListById getIdsDataById()
|
||||
public TagDataListById getRoot()
|
||||
{
|
||||
TagDataListById result;
|
||||
|
||||
|
@ -343,7 +428,7 @@ public class TagDataManager
|
|||
{
|
||||
SimpleTagData tag = this.getIdData(id);
|
||||
|
||||
tag.attributes().setAttribute("class", DomPresenterCore.NODISPLAY_CLASS);
|
||||
tag.setAttribute("class", DomPresenterCore.NODISPLAY_CLASS);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -379,7 +464,7 @@ public class TagDataManager
|
|||
{
|
||||
SimpleTagData tag = this.getIdData(id, line);
|
||||
|
||||
tag.attributes().setAttribute(label, value);
|
||||
tag.setAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -419,7 +504,7 @@ public class TagDataManager
|
|||
{
|
||||
SimpleTagData tag = this.getIdData(id, line, column);
|
||||
|
||||
tag.attributes().setAttribute(label, value);
|
||||
tag.setAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -451,7 +536,7 @@ public class TagDataManager
|
|||
{
|
||||
SimpleTagData tag = this.getIdData(id);
|
||||
|
||||
tag.attributes().setAttribute(label, value);
|
||||
tag.setAttribute(label, value);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -574,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.
|
||||
*
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2018 Christian Pierre MOMON
|
||||
* Copyright (C) 2006-2018,2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
|
@ -59,7 +59,7 @@ class XidynDemo
|
|||
String htmlSource = "<div id='pseudo'>a pseudo</div >";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setContent("name", "Superman");
|
||||
data.setContent("pseudo", "Superman");
|
||||
|
||||
String htmlTarget = PresenterUtils.dynamize(htmlSource, data).toString();
|
||||
|
||||
|
@ -73,7 +73,8 @@ class XidynDemo
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
System.out.println("Demo failed: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +107,8 @@ class XidynDemo
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
System.out.println("Demo failed: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -147,7 +149,8 @@ class XidynDemo
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
System.out.println("Demo failed: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +192,8 @@ class XidynDemo
|
|||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
System.out.println(exception.getMessage());
|
||||
System.out.println("Demo failed: " + exception.getMessage());
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2006-2018 Christian Pierre MOMON
|
||||
* Copyright (C) 2006-2018,2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
|
@ -34,7 +34,9 @@ import org.w3c.dom.Node;
|
|||
import org.w3c.dom.NodeList;
|
||||
|
||||
import fr.devinsy.xidyn.XidynException;
|
||||
import fr.devinsy.xidyn.data.DisplayMode;
|
||||
import fr.devinsy.xidyn.data.SimpleTagData;
|
||||
import fr.devinsy.xidyn.data.TagAttribute;
|
||||
import fr.devinsy.xidyn.data.TagAttributes;
|
||||
import fr.devinsy.xidyn.data.TagData;
|
||||
import fr.devinsy.xidyn.data.TagDataListById;
|
||||
|
@ -90,7 +92,7 @@ public class DomPresenterCore
|
|||
*/
|
||||
public static void dynamize(final Appendable result, final Document doc, final TagDataManager data) throws XidynException
|
||||
{
|
||||
dynamize(result, doc, data.getIdsDataById());
|
||||
dynamize(result, doc, data.getRoot());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -131,7 +133,7 @@ public class DomPresenterCore
|
|||
{
|
||||
StringBuffer result;
|
||||
|
||||
result = dynamize(doc, data.getIdsDataById());
|
||||
result = dynamize(doc, data.getRoot());
|
||||
|
||||
//
|
||||
return result;
|
||||
|
@ -171,133 +173,6 @@ public class DomPresenterCore
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text for an element. Converts new lines to spaces.
|
||||
*
|
||||
* @param node
|
||||
* the node
|
||||
* @return the element text
|
||||
*/
|
||||
private static String getElementText(final Node node)
|
||||
{
|
||||
String result;
|
||||
|
||||
NodeList children = node.getChildNodes();
|
||||
if ((children == null) || (children.getLength() == 0))
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean ended = false;
|
||||
result = ""; // Grrrr, Java ...
|
||||
int childCounter = 0;
|
||||
int childCount = children.getLength();
|
||||
while (!ended)
|
||||
{
|
||||
if (childCounter >= childCount)
|
||||
{
|
||||
ended = true;
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Node child = children.item(childCounter);
|
||||
if (child.getNodeType() == Node.TEXT_NODE)
|
||||
{
|
||||
// STU (+=, newLines...)
|
||||
result = newLinesToSpaces(child.getNodeValue());
|
||||
ended = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
childCounter += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge attributes.
|
||||
*
|
||||
* @param target
|
||||
* the target
|
||||
* @param source
|
||||
* the source
|
||||
* @return the tag attributes
|
||||
*/
|
||||
private static TagAttributes mergeAttributes(final TagAttributes target, final TagAttributes source)
|
||||
{
|
||||
TagAttributes result;
|
||||
|
||||
//
|
||||
if (target == null)
|
||||
{
|
||||
result = source;
|
||||
}
|
||||
else if (source == null)
|
||||
{
|
||||
result = target;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = new TagAttributes(target);
|
||||
|
||||
Iterator<Map.Entry<String, String>> iterator = source.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Map.Entry<String, String> attribute = iterator.next();
|
||||
|
||||
String currentValue = target.get(attribute.getKey());
|
||||
|
||||
if (currentValue == null)
|
||||
{
|
||||
result.put(attribute.getKey(), attribute.getValue());
|
||||
}
|
||||
else if (attribute.getKey().equals("style"))
|
||||
{
|
||||
result.put(attribute.getKey(), currentValue + attribute.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
result.put(attribute.getKey(), attribute.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts New Line characters to spaces. This is used when for example the
|
||||
* text in a div tag goes over several lines.
|
||||
*
|
||||
* @param text
|
||||
* String
|
||||
* @return String
|
||||
*/
|
||||
private static String newLinesToSpaces(final String text)
|
||||
{
|
||||
StringBuffer result = new StringBuffer(text);
|
||||
|
||||
for (int i = 0; i < result.length(); i++)
|
||||
{
|
||||
if (result.charAt(i) == '\n')
|
||||
{
|
||||
result.setCharAt(i, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return (result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Process.
|
||||
*
|
||||
|
@ -447,42 +322,6 @@ public class DomPresenterCore
|
|||
logger.debug("process - ended");
|
||||
}
|
||||
|
||||
/**
|
||||
* Process attributes.
|
||||
*
|
||||
* @param attrs
|
||||
* the attrs
|
||||
* @return the string buffer
|
||||
*/
|
||||
private static StringBuffer processAttributes(final NamedNodeMap attrs)
|
||||
{
|
||||
StringBuffer result;
|
||||
|
||||
result = processAttributes(attrs, null, null, "");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process attributes.
|
||||
*
|
||||
* @param attrs
|
||||
* the attrs
|
||||
* @param dataAttributes
|
||||
* the data attributes
|
||||
* @return the string buffer
|
||||
*/
|
||||
private static StringBuffer processAttributes(final NamedNodeMap attrs, final TagAttributes dataAttributes)
|
||||
{
|
||||
StringBuffer result;
|
||||
|
||||
result = processAttributes(attrs, dataAttributes, "");
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process attributes.
|
||||
*
|
||||
|
@ -512,26 +351,26 @@ public class DomPresenterCore
|
|||
// Put model attributes in the merged attributes list.
|
||||
if (dataAttributes != null)
|
||||
{
|
||||
Iterator<Map.Entry<String, String>> iterator = dataAttributes.entrySet().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
for (TagAttribute attribute : dataAttributes)
|
||||
{
|
||||
Map.Entry<String, String> attribute = iterator.next();
|
||||
|
||||
if (mergedAttributes.containsKey(attribute.getKey()))
|
||||
if (mergedAttributes.containsKey(attribute.getLabel()))
|
||||
{
|
||||
if (attribute.getKey().equalsIgnoreCase("style"))
|
||||
if (attribute.getMode() == DisplayMode.APPEND)
|
||||
{
|
||||
mergedAttributes.put(attribute.getKey(), mergedAttributes.get(attribute.getKey()) + attribute.getValue());
|
||||
mergedAttributes.put(attribute.getLabel(), mergedAttributes.get(attribute.getLabel()) + " " + attribute.getValue());
|
||||
}
|
||||
else if (attribute.getMode() == DisplayMode.REPLACE)
|
||||
{
|
||||
mergedAttributes.put(attribute.getLabel(), attribute.getValue());
|
||||
}
|
||||
else
|
||||
{
|
||||
mergedAttributes.put(attribute.getKey(), attribute.getValue());
|
||||
// Keep the already merged value.
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mergedAttributes.put(attribute.getKey(), attribute.getValue());
|
||||
mergedAttributes.put(attribute.getLabel(), attribute.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -556,46 +395,6 @@ public class DomPresenterCore
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process attributes.
|
||||
*
|
||||
* @param attrs
|
||||
* the attrs
|
||||
* @param dataAttributes
|
||||
* the data attributes
|
||||
* @param namedDataAttributes
|
||||
* the named data attributes
|
||||
* @param suffix
|
||||
* the suffix
|
||||
* @return the string buffer
|
||||
*/
|
||||
private static StringBuffer processAttributes(final NamedNodeMap attrs, final TagAttributes dataAttributes, final TagAttributes namedDataAttributes, final String suffix)
|
||||
{
|
||||
StringBuffer result;
|
||||
|
||||
result = processAttributes(attrs, mergeAttributes(dataAttributes, namedDataAttributes), suffix);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process children.
|
||||
*
|
||||
* @param result
|
||||
* the result
|
||||
* @param node
|
||||
* the node
|
||||
* @param datas
|
||||
* the datas
|
||||
* @throws IOException
|
||||
* the exception
|
||||
*/
|
||||
private static void processChildren(final Appendable result, final Node node, final TagDataListById datas) throws IOException
|
||||
{
|
||||
processChildren(result, node, datas, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Process children.
|
||||
*
|
||||
|
@ -738,23 +537,6 @@ public class DomPresenterCore
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO remove?.
|
||||
*
|
||||
* @param result
|
||||
* the result
|
||||
* @param node
|
||||
* the node
|
||||
* @param datas
|
||||
* the datas
|
||||
* @throws IOException
|
||||
* the exception
|
||||
*/
|
||||
private static void processElementBasically(final Appendable result, final Node node, final TagDataListById datas) throws IOException
|
||||
{
|
||||
processElementBasically(result, node, datas, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Process element basically.
|
||||
*
|
||||
|
@ -801,28 +583,6 @@ public class DomPresenterCore
|
|||
logger.debug("processElementBasically - ended");
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a node that has dynamic content. Calls the appropriate code
|
||||
* generator method, depending on the tag.
|
||||
*
|
||||
* @param result
|
||||
* the result
|
||||
* @param node
|
||||
* Current node.
|
||||
* @param attrs
|
||||
* The tag attributes.
|
||||
* @param idAttr
|
||||
* The ID.
|
||||
* @param datas
|
||||
* the datas
|
||||
* @throws IOException
|
||||
* the exception
|
||||
*/
|
||||
private static void processElementWithId(final Appendable result, final Node node, final NamedNodeMap attrs, final Node idAttr, final TagDataListById datas) throws IOException
|
||||
{
|
||||
processElementWithId(result, node, attrs, idAttr, datas, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes a node that has dynamic content. Calls the appropriate code
|
||||
* generator method, depending on the tag.
|
||||
|
@ -861,7 +621,7 @@ public class DomPresenterCore
|
|||
{
|
||||
SimpleTagData data = (SimpleTagData) dataCore;
|
||||
|
||||
String theClass = data.attributes().getAttribute("class");
|
||||
String theClass = data.getAttributeValue("class");
|
||||
|
||||
if ((theClass == null) || (!theClass.equals(NODISPLAY_CLASS)))
|
||||
{
|
||||
|
@ -872,7 +632,7 @@ public class DomPresenterCore
|
|||
// Build attributes.
|
||||
result.append(processAttributes(attrs, data.attributes(), suffix));
|
||||
|
||||
if (((node.getChildNodes() == null) || (node.getChildNodes().getLength() == 0)) && ((data == null) || (data.display() == null)))
|
||||
if (((node.getChildNodes() == null) || (node.getChildNodes().getLength() == 0)) && ((data == null) || (data.getContent() == null)))
|
||||
{
|
||||
// Close the tag.
|
||||
result.append(" />");
|
||||
|
@ -881,16 +641,14 @@ public class DomPresenterCore
|
|||
{
|
||||
result.append('>');
|
||||
|
||||
// CHANGED, cpm:
|
||||
|
||||
// Insert data.
|
||||
if ((data == null) || (data.display() == null))
|
||||
if ((data == null) || (data.getContent() == null))
|
||||
{
|
||||
processChildren(result, node, datas, suffix);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append(data.display());
|
||||
result.append(data.getContent());
|
||||
}
|
||||
|
||||
// Close the tag.
|
||||
|
@ -904,20 +662,20 @@ public class DomPresenterCore
|
|||
{
|
||||
TagDataListByIndex tags = (TagDataListByIndex) dataCore;
|
||||
|
||||
int nbLines = tags.size();
|
||||
for (int nLine = 0; nLine < nbLines; nLine++)
|
||||
int lineCount = tags.size();
|
||||
for (int lineIndex = 0; lineIndex < lineCount; lineIndex++)
|
||||
{
|
||||
if (tags.elementAt(nLine) instanceof SimpleTagData)
|
||||
if (tags.elementAt(lineIndex) instanceof SimpleTagData)
|
||||
{
|
||||
SimpleTagData data = (SimpleTagData) tags.elementAt(nLine);
|
||||
SimpleTagData data = (SimpleTagData) tags.elementAt(lineIndex);
|
||||
|
||||
// Open the tag.
|
||||
result.append("<");
|
||||
result.append(node.getNodeName());
|
||||
|
||||
result.append(processAttributes(attrs, data.attributes(), Integer.toString(nLine)));
|
||||
result.append(processAttributes(attrs, data.attributes(), Integer.toString(lineIndex)));
|
||||
|
||||
if (((node.getChildNodes() == null) || (node.getChildNodes().getLength() == 0)) && ((data == null) || (data.display() == null)))
|
||||
if (((node.getChildNodes() == null) || (node.getChildNodes().getLength() == 0)) && ((data == null) || (data.getContent() == null)))
|
||||
{
|
||||
// Close the tag.
|
||||
result.append(" />\n");
|
||||
|
@ -929,13 +687,13 @@ public class DomPresenterCore
|
|||
// CHANGED, cpm
|
||||
|
||||
// Insert data.
|
||||
if ((data == null) || (data.display() == null))
|
||||
if ((data == null) || (data.getContent() == null))
|
||||
{
|
||||
processChildren(result, node, datas, suffix);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.append(data.display());
|
||||
result.append(data.getContent());
|
||||
}
|
||||
|
||||
// Close the tag.
|
||||
|
@ -947,9 +705,9 @@ public class DomPresenterCore
|
|||
else
|
||||
{
|
||||
// Manage a Hashmap.
|
||||
TagDataListById data = (TagDataListById) tags.elementAt(nLine);
|
||||
TagDataListById data = (TagDataListById) tags.elementAt(lineIndex);
|
||||
|
||||
processElementWithId(result, node, attrs, idAttr, data, Integer.toString(nLine));
|
||||
processElementWithId(result, node, attrs, idAttr, data, Integer.toString(lineIndex));
|
||||
result.append('\n');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
{
|
||||
|
|
|
@ -109,7 +109,7 @@ public class URLPresenter extends StringPresenter
|
|||
{
|
||||
StringBuffer result;
|
||||
|
||||
logger.info("dynamize URL [" + this.sourcePathname + "]");
|
||||
logger.debug("dynamize URL [{}]", this.sourcePathname);
|
||||
|
||||
//
|
||||
update();
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
@ -518,6 +547,95 @@ public class XidynUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the text for an element. Converts new lines to spaces.
|
||||
*
|
||||
* @param node
|
||||
* the node
|
||||
* @return the element text
|
||||
*/
|
||||
public static String getElementText(final Node node)
|
||||
{
|
||||
String result;
|
||||
|
||||
NodeList children = node.getChildNodes();
|
||||
if ((children == null) || (children.getLength() == 0))
|
||||
{
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean ended = false;
|
||||
result = ""; // Grrrr, Java ...
|
||||
int childCounter = 0;
|
||||
int childCount = children.getLength();
|
||||
while (!ended)
|
||||
{
|
||||
if (childCounter >= childCount)
|
||||
{
|
||||
ended = true;
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
Node child = children.item(childCounter);
|
||||
if (child.getNodeType() == Node.TEXT_NODE)
|
||||
{
|
||||
// STU (+=, newLines...)
|
||||
result = newLinesToSpaces(child.getNodeValue());
|
||||
ended = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
childCounter += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
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.
|
||||
*
|
||||
|
@ -661,6 +779,30 @@ public class XidynUtils
|
|||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts New Line characters to spaces. This is used when for example the
|
||||
* text in a div tag goes over several lines.
|
||||
*
|
||||
* @param text
|
||||
* String
|
||||
* @return String
|
||||
*/
|
||||
public static String newLinesToSpaces(final String text)
|
||||
{
|
||||
StringBuffer result = new StringBuffer(text);
|
||||
|
||||
for (int letterIndex = 0; letterIndex < result.length(); letterIndex++)
|
||||
{
|
||||
if (result.charAt(letterIndex) == '\n')
|
||||
{
|
||||
result.setCharAt(letterIndex, ' ');
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return (result.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Read.
|
||||
*
|
||||
|
@ -714,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..
|
||||
|
|
279
test/fr/devinsy/xidyn/data/TagDataManagerTest.java
Normal file
279
test/fr/devinsy/xidyn/data/TagDataManagerTest.java
Normal file
|
@ -0,0 +1,279 @@
|
|||
/*
|
||||
* Copyright (C) 2020 Christian Pierre MOMON
|
||||
*
|
||||
* This file is part of Xidyn.
|
||||
*
|
||||
* Xidyn is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Xidyn is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Xidyn. If not, see <http://www.gnu.org/licenses/>
|
||||
*/
|
||||
package fr.devinsy.xidyn.data;
|
||||
|
||||
import org.fest.assertions.Assertions;
|
||||
import org.junit.Test;
|
||||
|
||||
import fr.devinsy.xidyn.presenters.PresenterUtils;
|
||||
|
||||
/**
|
||||
* The Class TagDataManagerTest.
|
||||
*/
|
||||
public class TagDataManagerTest
|
||||
{
|
||||
/**
|
||||
* Test 01.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test01() throws Exception
|
||||
{
|
||||
String source = "<ul><li id='line'>line 1</li></ul>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setContent("line", 0, "Alpha");
|
||||
data.appendAttribute("line", 0, "style", "background: red;");
|
||||
data.setContent("line", 1, "Bravo");
|
||||
data.appendAttribute("line", 1, "style", "background: blue;");
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<ul><li style=\"background: red;\" id=\"line_0\">Alpha</li>\n<li style=\"background: blue;\" id=\"line_1\">Bravo</li>\n</ul>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test02() throws Exception
|
||||
{
|
||||
String source = "<table><tr id='line'><td id='col1'>id</td><td id='name'>name</td></tr></table>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setContent("line", 0, "col1", "Alpha");
|
||||
data.appendAttribute("line", 0, "col1", "style", "background: red;");
|
||||
data.setContent("line", 1, "Bravo");
|
||||
data.appendAttribute("line", 1, "style", "background: blue;");
|
||||
|
||||
String target = PresenterUtils.dynamize(source, null).toString();
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 03.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test03a() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' class='bare'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "class", "goodClass");
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span id=\"foo\" class=\"bare goodClass\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 04.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test03b() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' class='bare'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "class", "goodClass");
|
||||
data.getIdData("foo").setAttributeMode("class", DisplayMode.APPEND);
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span id=\"foo\" class=\"bare goodClass\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 05.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test03c() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' class='bare'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "class", "goodClass");
|
||||
data.getIdData("foo").setAttributeMode("class", DisplayMode.REPLACE);
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span id=\"foo\" class=\"goodClass\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 06.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test06a() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' style='width: 100px;'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "style", "goodStyle;");
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span style=\"width: 100px; goodStyle;\" id=\"foo\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test06b() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' style='width: 100px;'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "style", "goodStyle;");
|
||||
data.getIdData("foo").setAttributeMode("style", DisplayMode.APPEND);
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span style=\"width: 100px; goodStyle;\" id=\"foo\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 06 c.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test06c() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' style='width: 100px;'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "style", "goodStyle;");
|
||||
data.getIdData("foo").setAttributeMode("style", DisplayMode.REPLACE);
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span style=\"goodStyle;\" id=\"foo\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 9a.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test09a() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' name='bare'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "name", "good;");
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span name=\"good;\" id=\"foo\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 9 b.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test09b() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' name='bare'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "name", "good;");
|
||||
data.getIdData("foo").setAttributeMode("name", DisplayMode.REPLACE);
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span name=\"good;\" id=\"foo\">FOOO</span>";
|
||||
|
||||
Assertions.assertThat(target).isEqualTo(goal);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test 9 c.
|
||||
*
|
||||
* @throws Exception
|
||||
* the exception
|
||||
*/
|
||||
@Test
|
||||
public void test09c() throws Exception
|
||||
{
|
||||
String source = "<span id='foo' name='bare'>FOOO</span>";
|
||||
|
||||
TagDataManager data = new TagDataManager();
|
||||
data.setAttribute("foo", "name", "good;");
|
||||
data.getIdData("foo").setAttributeMode("name", DisplayMode.APPEND);
|
||||
|
||||
String target = PresenterUtils.dynamize(source, data).toString();
|
||||
|
||||
String goal = "<span name=\"bare good;\" id=\"foo\">FOOO</span>";
|
||||
|
||||
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