Skip to content

Commit

Permalink
Merge pull request #90 from sesteel/master
Browse files Browse the repository at this point in the history
Disable Findbugs Temporarily and Remove Charset Reliance
  • Loading branch information
sesteel committed Feb 24, 2014
2 parents 88e253e + 0be05f6 commit f1d10aa
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 202 deletions.
12 changes: 0 additions & 12 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'findbugs'

buildscript {
repositories {
Expand Down Expand Up @@ -96,17 +95,6 @@ compileJava {
options.fork = true
}

findbugs {
reportLevel = "high"
}

tasks.withType(FindBugs) {
reports {
xml.enabled = false
html.enabled = true
}
}

task getVersion << {
println version
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Project details
group=com.readytalk
version=1.2.0-SNAPSHOT
version=2.0.0


# Optimize the build environment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.readytalk.swt.text.tokenizer;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -15,18 +14,6 @@ class PlainTextTokenizer implements TextTokenizer {
private static final String WHITESPACE_REGEX = "\\s+";

private List<TextToken> tokens = new ArrayList<TextToken>();
private Charset encoding = Charset.defaultCharset();

@Override
public TextTokenizer setEncoding(Charset encoding) {
this.encoding = encoding;
return this;
}

@Override
public Charset getEncoding() {
return encoding;
}

@Override
public TextTokenizer reset() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
package com.readytalk.swt.text.tokenizer;

import java.nio.charset.Charset;
import java.util.List;

/**
* TextTokenizer is an interface to be implemented by text tokenizers wanting
* to be constructed by the TextTokenizerFactory.
*/
public interface TextTokenizer {

/**
* Set the character encoding for the text tokenizer.
*/
TextTokenizer setEncoding(Charset encoding);

/**
* Get the character encoding of the text tokenizer.
*/
Charset getEncoding();
public interface TextTokenizer {

/**
* Reset the tokenizer to its deafult state.
Expand Down
22 changes: 5 additions & 17 deletions src/main/resources/ragel/FormattedTextTokenizer.java.rl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.nio.charset.Charset;

import org.eclipse.swt.SWT;

Expand All @@ -17,23 +16,11 @@ import com.readytalk.swt.text.painter.TextType;
* ragel -J FormattedTextTokenizer.java.rl -o FormattedTextTokenizer.java
*/
public class FormattedTextTokenizer implements TextTokenizer {

private Charset encoding = Charset.defaultCharset();

private List<TextToken> tokens = new ArrayList<TextToken>();

private int styleState = 0x00;

@Override
public FormattedTextTokenizer setEncoding(final Charset encoding) {
this.encoding = encoding;
return this;
}

@Override
public Charset getEncoding() {
return encoding;
}

@Override
public FormattedTextTokenizer reset() {
tokens.clear();
Expand All @@ -56,9 +43,10 @@ public class FormattedTextTokenizer implements TextTokenizer {
System.arraycopy(data, start, splicedData, 0, length);
return splicedData;
}


@SuppressWarnings("unchecked")
String spliceToString(final byte[] data, final int start, final int end) {
return new String(splice(data, start, end), encoding);
return new String(splice(data, start, end));
}

@Override
Expand All @@ -68,7 +56,7 @@ public class FormattedTextTokenizer implements TextTokenizer {
return tokens;
}

byte[] data = text.getBytes(encoding);
byte[] data = text.getBytes();
int eof = data.length;

// the names of these variables are specified by the ragel parser generator
Expand Down
Loading

0 comments on commit f1d10aa

Please sign in to comment.