<commit_before>/**
 * Copyright 2008-2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aspectran.core.context.expr.token;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.aspectran.core.context.rule.type.TokenType;
import com.aspectran.core.context.rule.type.TokenDirectiveType;

/**
 * The Class Tokenizer.
 * 
 * <p>Created: 2008. 03. 29 AM 1:55:03</p>
 */
public class Tokenizer {

	private static final int MAX_TOKEN_NAME_LENGTH = 256;

	private static final int AT_STRING = 1;

	private static final int AT_TOKEN_SYMBOL = 2;

	private static final int AT_TOKEN_NAME = 3;

	private static final int AT_TOKEN_DEFVAL = 4;
	
	private static final char CR = '\r';

	private static final char LF = '\n';

	private static final String DIRECTIVE_CLASS = "class";

	private static final String DIRECTIVE_CLASSPATH = "classpath";

	/**
	 * Tokenize a string and returns a list of tokens.
	 * 
	 * @param input the string to tokenize
	 * @param trimStringToken the trim string token
	 * @return the token list
	 */
	public static List<Token> tokenize(CharSequence input, boolean trimStringToken) {
		List<Token> tokens = new ArrayList<>();

		int inputLen = input.length();

		int status = AT_STRING;
		int tokenStartOffset = 0; // start position of token in the stringBuffer
		char symbol = Token.PARAMETER_SYMBOL; // PARAMETER_SYMBOL or ATTRIBUTE_SYMBOL
		char c;

		StringBuilder stringBuffer = new StringBuilder();
		StringBuilder tokenNameBuffer = new StringBuilder();
		StringBuilder defTextBuffer = new StringBuilder();

		for(int i = 0; i < inputLen; i++) {
			c = input.charAt(i);

			switch(status) {
			case AT_STRING:
				stringBuffer.append(c);

				if(Token.isTokenSymbol(c)) {<commit_msg>Unused static variable are removed.<commit_after>/**
 * Copyright 2008-2016 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.aspectran.core.context.expr.token;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import com.aspectran.core.context.rule.type.TokenType;
import com.aspectran.core.context.rule.type.TokenDirectiveType;

/**
 * The Class Tokenizer.
 * 
 * <p>Created: 2008. 03. 29 AM 1:55:03</p>
 */
public class Tokenizer {

	private static final int MAX_TOKEN_NAME_LENGTH = 256;

	private static final int AT_STRING = 1;

	private static final int AT_TOKEN_SYMBOL = 2;

	private static final int AT_TOKEN_NAME = 3;

	private static final int AT_TOKEN_DEFVAL = 4;
	
	private static final char CR = '\r';

	private static final char LF = '\n';

	/**
	 * Tokenize a string and returns a list of tokens.
	 * 
	 * @param input the string to tokenize
	 * @param trimStringToken the trim string token
	 * @return the token list
	 */
	public static List<Token> tokenize(CharSequence input, boolean trimStringToken) {
		List<Token> tokens = new ArrayList<>();

		int inputLen = input.length();

		int status = AT_STRING;
		int tokenStartOffset = 0; // start position of token in the stringBuffer
		char symbol = Token.PARAMETER_SYMBOL; // PARAMETER_SYMBOL or ATTRIBUTE_SYMBOL
		char c;

		StringBuilder stringBuffer = new StringBuilder();
		StringBuilder tokenNameBuffer = new StringBuilder();
		StringBuilder defTextBuffer = new StringBuilder();

		for(int i = 0; i < inputLen; i++) {
			c = input.charAt(i);

			switch(status) {
			case AT_STRING:
				stringBuffer.append(c);

				if(Token.isTokenSymbol(c)) {
{'fraction_non_alphanumeric': 0.09285071942446044, 'fraction_numerical': 0.015287769784172662, 'mean_word_length': 3.910596026490066, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3109562', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1269, 'n_words': 482}