Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to SLF4J #22

Merged
merged 2 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@
<artifactId>exificient-core</artifactId>
<version>1.0.5-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.6</version>
</dependency>
<!-- Runtime Dependencies (schema-informed mode) -->
<dependency>
<groupId>xerces</groupId>
Expand All @@ -75,6 +80,12 @@
<version>1.0.4</version><!-- -SNAPSHOT -->
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.6</version>
<scope>test</scope>
</dependency>
</dependencies>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
import org.apache.xerces.xs.XSParticle;
import org.apache.xerces.xs.XSTerm;
import org.apache.xerces.xs.XSWildcard;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.siemens.ct.exi.core.exceptions.EXIException;
import com.siemens.ct.exi.core.grammars.event.AttributeGeneric;
Expand All @@ -86,7 +88,8 @@
public abstract class EXIContentModelBuilder extends CMBuilder implements
XMLErrorHandler {

private static final boolean DEBUG = false;
/** The logger used in this class. */
private static final Logger LOGGER = LoggerFactory.getLogger(EXIContentModelBuilder.class);

protected static final Event END_ELEMENT = new EndElement();
protected static final Event START_ELEMENT_GENERIC = new StartElementGeneric();
Expand Down Expand Up @@ -333,9 +336,7 @@ protected SchemaInformedGrammar handleParticle(XSComplexTypeDefinition ctd,

CMState startState = new CMState(possibleElements, isEnd, state,
elementsMaxOccursUnbounded, occurenceInfo);
if (DEBUG) {
System.out.println("Start = " + startState);
}
LOGGER.debug("Start = {}", startState);

Map<CMState, SchemaInformedGrammar> knownStates = new HashMap<CMState, SchemaInformedGrammar>();
addNewState(knownStates, startState, isMixedContent);
Expand Down Expand Up @@ -568,10 +569,7 @@ protected List<XSElementDeclaration> getPossibleElementDeclarations(

private static void printTransition(CMState startState, XSObject xs,
CMState nextState) {
if (DEBUG) {
System.out.println("\t" + startState + " --> " + xs + " --> "
+ nextState);
}
LOGGER.debug("\t{} --> {} --> {}", startState, xs, nextState);
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import java.util.ArrayList;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.siemens.ct.exi.core.context.GrammarContext;
import com.siemens.ct.exi.core.context.GrammarUriContext;
import com.siemens.ct.exi.core.context.QNameContext;
Expand Down Expand Up @@ -72,6 +75,9 @@

public class Grammars2JSON {

/** The logger used in this class. */
private static final Logger LOGGER = LoggerFactory.getLogger(Grammars2JSON.class);

public static final PrintStream ps = System.out;

public static final boolean STATS_ON = true;
Expand Down Expand Up @@ -546,7 +552,7 @@ protected void printGrammarProduction(Writer w, int ind,
GrammarsConstants.CHARACTERS_GENERIC);
break;
default:
System.err.println("Unknown Event " + ei.getEvent());
LOGGER.error("Unknown Event {}", ei.getEvent());
}

// next state ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
import java.io.StringWriter;
import java.math.BigInteger;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.siemens.ct.exi.core.context.GrammarContext;
import com.siemens.ct.exi.core.context.GrammarUriContext;
import com.siemens.ct.exi.core.context.QNameContext;
Expand Down Expand Up @@ -46,6 +49,9 @@

public class Grammars2JavaSourceCode {

/** The logger used in this class. */
private static final Logger LOGGER = LoggerFactory.getLogger(Grammars2JavaSourceCode.class);

protected static final String TOKEN_GRAMMAR_CONTEXT_BEGIN = "/* BEGIN GrammarContext ----- */";
protected static final String TOKEN_GRAMMAR_CONTEXT_END = "/* END GrammarContext ----- */";

Expand Down Expand Up @@ -399,8 +405,7 @@ public void generateCode() throws IOException {
SchemaInformedStartTag sist = (SchemaInformedStartTag) r;
Grammar elementContentGrammar = sist.getElementContentGrammar();
if (elementContentGrammar instanceof SchemaInformedStartTag) {
System.err.println("Error for " + sist + " and "
+ elementContentGrammar);
LOGGER.error("Error for {} and {}", sist, elementContentGrammar);
}
int elementContentGrammarID = gpreps
.getGrammarID(elementContentGrammar);
Expand Down
30 changes: 11 additions & 19 deletions src/main/java/com/siemens/ct/exi/grammars/regex/REUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@

import java.text.CharacterIterator;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

//import org.apache.xerces.impl.xpath.regex.Match;
//import org.apache.xerces.impl.xpath.regex.ParseException;

Expand All @@ -30,6 +33,10 @@
* @version $Id: REUtil.java 828015 2009-10-21 13:56:13Z knoaman $
*/
public final class REUtil {

/** The logger used in this class. */
private static final Logger LOGGER = LoggerFactory.getLogger(REUtil.class);

private REUtil() {
}

Expand Down Expand Up @@ -229,7 +236,7 @@ public static void main(String[] argv) {
else if (target == null)
target = argv[i];
else
System.err.println("Unnecessary: " + argv[i]);
LOGGER.warn("Unnecessary: {}", argv[i]);
} else if (argv[i].equals("-i")) {
options += "i";
} else if (argv[i].equals("-m")) {
Expand All @@ -243,7 +250,7 @@ else if (target == null)
} else if (argv[i].equals("-X")) {
options += "X";
} else {
System.err.println("Unknown option: " + argv[i]);
LOGGER.warn("Unknown option: {}", argv[i]);
}
}
RegularExpression reg = new RegularExpression(pattern, options);
Expand All @@ -264,24 +271,9 @@ else if (target == null)
}
}
} catch (ParseException pe) {
if (pattern == null) {
pe.printStackTrace();
} else {
System.err
.println("org.apache.xerces.utils.regex.ParseException: "
+ pe.getMessage());
String indent = " ";
System.err.println(indent + pattern);
int loc = pe.getLocation();
if (loc >= 0) {
System.err.print(indent);
for (int i = 0; i < loc; i++)
System.err.print("-");
System.err.println("^");
}
}
LOGGER.error("unexpected ParseException", pe);
} catch (Exception e) {
e.printStackTrace();
LOGGER.error("unexpected error", e);
}
}

Expand Down
68 changes: 27 additions & 41 deletions src/main/java/com/siemens/ct/exi/grammars/regex/RangeToken.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.siemens.ct.exi.grammars.regex;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
Expand Down Expand Up @@ -30,6 +33,9 @@ final class RangeToken extends Token implements java.io.Serializable {

private static final long serialVersionUID = -553983121197679934L;

/** The logger used in this class. */
private static final Logger LOGGER = LoggerFactory.getLogger(RangeToken.class);

int[] ranges;
boolean sorted;
boolean compacted;
Expand Down Expand Up @@ -129,7 +135,6 @@ protected void sortRanges() {
* this.ranges is sorted.
*/
protected void compactRanges() {
boolean DEBUG = false;
if (this.ranges == null || this.ranges.length <= 2)
return;
if (this.isCompacted())
Expand All @@ -148,39 +153,33 @@ protected void compactRanges() {
if (baseend + 1 < this.ranges[target])
break;
if (baseend + 1 == this.ranges[target]) {
if (DEBUG)
System.err
.println("Token#compactRanges(): Compaction: ["
+ this.ranges[base] + ", "
+ this.ranges[base + 1] + "], ["
+ this.ranges[target] + ", "
+ this.ranges[target + 1] + "] -> ["
+ this.ranges[base] + ", "
+ this.ranges[target + 1] + "]");
LOGGER.debug("Token#compactRanges(): Compaction: [{}, {}], [{}, {}] -> [{}, {}]",
this.ranges[base],
this.ranges[base + 1],
this.ranges[target],
this.ranges[target + 1],
this.ranges[base],
this.ranges[target + 1]);
this.ranges[base + 1] = this.ranges[target + 1];
baseend = this.ranges[base + 1];
target += 2;
} else if (baseend >= this.ranges[target + 1]) {
if (DEBUG)
System.err
.println("Token#compactRanges(): Compaction: ["
+ this.ranges[base] + ", "
+ this.ranges[base + 1] + "], ["
+ this.ranges[target] + ", "
+ this.ranges[target + 1] + "] -> ["
+ this.ranges[base] + ", "
+ this.ranges[base + 1] + "]");
LOGGER.debug("Token#compactRanges(): Compaction: [{}, {}], [{}, {}] -> [{}, {}]",
this.ranges[base],
this.ranges[base + 1],
this.ranges[target],
this.ranges[target + 1],
this.ranges[base],
this.ranges[base + 1]);
target += 2;
} else if (baseend < this.ranges[target + 1]) {
if (DEBUG)
System.err
.println("Token#compactRanges(): Compaction: ["
+ this.ranges[base] + ", "
+ this.ranges[base + 1] + "], ["
+ this.ranges[target] + ", "
+ this.ranges[target + 1] + "] -> ["
+ this.ranges[base] + ", "
+ this.ranges[target + 1] + "]");
LOGGER.debug("Token#compactRanges(): Compaction: [{}, {}], [{}, {}] -> [{}, {}]",
this.ranges[base],
this.ranges[base + 1],
this.ranges[target],
this.ranges[target + 1],
this.ranges[base],
this.ranges[target + 1]);
this.ranges[base + 1] = this.ranges[target + 1];
baseend = this.ranges[base + 1];
target += 2;
Expand Down Expand Up @@ -500,19 +499,6 @@ synchronized RangeToken getCaseInsensitiveToken() {
return lowers;
}

void dumpRanges() {
System.err.print("RANGE: ");
if (this.ranges == null) {
System.err.println(" NULL");
return;
}
for (int i = 0; i < this.ranges.length; i += 2) {
System.err.print("[" + this.ranges[i] + "," + this.ranges[i + 1]
+ "] ");
}
System.err.println("");
}

boolean match(int ch) {
if (this.map == null)
this.createMap();
Expand Down
Loading