You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ta...@apache.org on 2022/06/27 07:12:35 UTC
[myfaces] branch master updated: Reuse expression and avoid duplicate code.Easier to maintain. (#280)
This is an automated email from the ASF dual-hosted git repository.
tandraschko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/myfaces.git
The following commit(s) were added to refs/heads/master by this push:
new 6e995af7c Reuse expression and avoid duplicate code.Easier to maintain. (#280)
6e995af7c is described below
commit 6e995af7c0506d0fdcb1f09ba53293b5f38f8b10
Author: Arturo Bernal <ar...@gmail.com>
AuthorDate: Mon Jun 27 09:12:31 2022 +0200
Reuse expression and avoid duplicate code.Easier to maintain. (#280)
---
.../config/DefaultFacesConfigurationProvider.java | 6 ++----
.../view/facelets/compiler/SAXCompiler.java | 24 ++++++++++------------
2 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java b/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
index 955e93972..17dcf9c11 100644
--- a/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
+++ b/impl/src/main/java/org/apache/myfaces/config/DefaultFacesConfigurationProvider.java
@@ -659,6 +659,7 @@ public class DefaultFacesConfigurationProvider extends FacesConfigurationProvide
}
String flowName = systemId.substring(systemId.lastIndexOf('/')+1, systemId.lastIndexOf("-flow.xml"));
int c = pbstream.read();
+ final String startNodePath = systemId.substring(0, systemId.lastIndexOf('/') + 1) + flowName + ".xhtml";
if (c != -1)
{
pbstream.unread(c);
@@ -673,8 +674,7 @@ public class DefaultFacesConfigurationProvider extends FacesConfigurationProvide
flow.setId(flowName);
// In this case the defining document id is implicit associated
flow.setDefiningDocumentId(systemId);
-
- String startNodePath = systemId.substring(0, systemId.lastIndexOf('/')+1)+flowName+".xhtml";
+
flow.setStartNode(startNodePath);
// There is a default return node with name [flow-name]-return and
@@ -705,8 +705,6 @@ public class DefaultFacesConfigurationProvider extends FacesConfigurationProvide
FacesFlowDefinitionImpl flow = (FacesFlowDefinitionImpl) definition;
if (flow.getStartNode() == null)
{
- String startNodePath = systemId.substring(0,
- systemId.lastIndexOf('/')+1)+flowName+".xhtml";
flow.setStartNode(startNodePath);
}
}
diff --git a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
index 5eb99ade9..1f0092239 100644
--- a/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
+++ b/impl/src/main/java/org/apache/myfaces/view/facelets/compiler/SAXCompiler.java
@@ -631,14 +631,15 @@ public final class SAXCompiler extends Compiler
@Override
public void endElement(String uri, String localName, String qName) throws SAXException
{
+ final boolean hasNameSpace = CompositeLibrary.NAMESPACE.equals(uri)
+ || CompositeLibrary.JCP_NAMESPACE.equals(uri)
+ || CompositeLibrary.SUN_NAMESPACE.equals(uri);
if (inCompositeInterface)
{
this.unit.popTag();
}
- else if (inCompositeImplementation &&
- (CompositeLibrary.NAMESPACE.equals(uri)
- || CompositeLibrary.JCP_NAMESPACE.equals(uri)
- || CompositeLibrary.SUN_NAMESPACE.equals(uri)))
+ else if (inCompositeImplementation &&
+ hasNameSpace)
{
if ("insertFacet".equals(localName) ||
"renderFacet".equals(localName) ||
@@ -649,9 +650,7 @@ public final class SAXCompiler extends Compiler
}
}
- if (CompositeLibrary.NAMESPACE.equals(uri)
- || CompositeLibrary.JCP_NAMESPACE.equals(uri)
- || CompositeLibrary.SUN_NAMESPACE.equals(uri))
+ if (hasNameSpace)
{
if (InterfaceHandler.NAME.equals(localName))
{
@@ -746,9 +745,10 @@ public final class SAXCompiler extends Compiler
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException
{
- if (CompositeLibrary.NAMESPACE.equals(uri)
+ final boolean nameSpace = CompositeLibrary.NAMESPACE.equals(uri)
|| CompositeLibrary.JCP_NAMESPACE.equals(uri)
- || CompositeLibrary.SUN_NAMESPACE.equals(uri))
+ || CompositeLibrary.SUN_NAMESPACE.equals(uri);
+ if (nameSpace)
{
if (InterfaceHandler.NAME.equals(localName))
{
@@ -764,10 +764,8 @@ public final class SAXCompiler extends Compiler
{
this.unit.pushTag(new Tag(createLocation(), uri, localName, qName, createAttributes(attributes)));
}
- else if (inCompositeImplementation &&
- (CompositeLibrary.NAMESPACE.equals(uri)
- || CompositeLibrary.JCP_NAMESPACE.equals(uri)
- || CompositeLibrary.SUN_NAMESPACE.equals(uri)))
+ else if (inCompositeImplementation &&
+ (nameSpace))
{
if ("insertFacet".equals(localName) ||
"renderFacet".equals(localName) ||