Skip to content
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
48 changes: 21 additions & 27 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

<groupId>org.mybatis.scripting</groupId>
<artifactId>mybatis-velocity</artifactId>
<version>1.5-SNAPSHOT</version>
<version>2.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>MyBatis Velocity</name>
Expand Down Expand Up @@ -62,6 +62,17 @@
<properties>
<findbugs.onlyAnalyze>org.mybatis.scripting.velocity.*</findbugs.onlyAnalyze>
<gcu.product>Velocity</gcu.product>

<!-- Maven set to java 7 to align with new velocity -->
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.testTarget>1.7</maven.compiler.testTarget>
<maven.compiler.testSource>1.7</maven.compiler.testSource>

<!-- Animal Sniffer Signature -->
<signature.group>org.codehaus.mojo.signature</signature.group>
<signature.artifact>java17</signature.artifact>
<signature.version>1.0</signature.version>
</properties>

<dependencies>
Expand All @@ -72,18 +83,13 @@
</dependency>
<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.7</version>
<artifactId>velocity-engine-core</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
<!-- TEST -->
<dependency>
Expand All @@ -99,32 +105,20 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>log4j.configuration</name>
<value>file:src/test/resources/log4j.xml</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<arguments>-Prelease,bundle</arguments>
<releaseProfiles>release,bundle</releaseProfiles>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,9 +24,9 @@ public final class FastLinkedList<E extends Serializable> implements Serializabl

private static final long serialVersionUID = 1L;

private Node first = null;
private Node first;

private Node last = null;
private Node last;

public FastLinkedList() {
this.last = this.first;
Expand Down
18 changes: 5 additions & 13 deletions src/main/java/org/mybatis/scripting/velocity/InDirective.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
import java.util.Iterator;

import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.directive.StopCommand;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.node.ASTReference;
import org.apache.velocity.runtime.parser.node.ASTStringLiteral;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.ParserTreeConstants;
import org.apache.velocity.util.introspection.Info;

/**
Expand Down Expand Up @@ -59,7 +56,7 @@ public String getName() {
}

@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) {
super.init(rs, context, node);
final int n = node.jjtGetNumChildren() - 1;
for (int i = 1; i < n; i++) {
Expand All @@ -74,12 +71,8 @@ public void init(RuntimeServices rs, InternalContextAdapter context, Node node)
}
else if (child.getType() == ParserTreeConstants.JJTSTRINGLITERAL) {
String value = (String) ((ASTStringLiteral) child).value(context);
switch (i) {
case 2:
this.column = value;
break;
default:
break;
if (i == 2) {
this.column = value;
}
}
else {
Expand All @@ -90,8 +83,7 @@ else if (child.getType() == ParserTreeConstants.JJTSTRINGLITERAL) {
}

@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException, ResourceNotFoundException,
ParseErrorException, MethodInvocationException {
public boolean render(InternalContextAdapter context, Writer writer, Node node) throws IOException {
Object listObject = node.jjtGetChild(0).value(context);
if (listObject == null) {
return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -24,7 +24,7 @@
public class ParameterMappingCollector {

private final ParameterMapping[] parameterMappingSources;
private final List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
private final List<ParameterMapping> parameterMappings = new ArrayList<>();
private final Map<String, Object> context;
private final Configuration configuration;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -56,7 +56,7 @@ public String getSql() {

private static class ParameterMappingTokenHandler extends BaseBuilder implements TokenHandler {

private final List<ParameterMapping> parameterMappings = new ArrayList<ParameterMapping>();
private final List<ParameterMapping> parameterMappings = new ArrayList<>();
private final Class<?> parameterType;

public ParameterMappingTokenHandler(Configuration newConfiguration, Class<?> newParameterType) {
Expand Down
20 changes: 6 additions & 14 deletions src/main/java/org/mybatis/scripting/velocity/RepeatDirective.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -21,19 +21,16 @@
import java.util.Iterator;
import org.apache.velocity.context.ChainedInternalContextAdapter;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.exception.TemplateInitException;
import org.apache.velocity.exception.VelocityException;
import org.apache.velocity.runtime.RuntimeServices;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.directive.Scope;
import org.apache.velocity.runtime.directive.StopCommand;
import org.apache.velocity.runtime.parser.ParserTreeConstants;
import org.apache.velocity.runtime.parser.node.ASTReference;
import org.apache.velocity.runtime.parser.node.ASTStringLiteral;
import org.apache.velocity.runtime.parser.node.Node;
import org.apache.velocity.runtime.parser.node.ParserTreeConstants;
import org.apache.velocity.util.introspection.Info;

/**
Expand All @@ -56,7 +53,7 @@ public String getName() {
}

@Override
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) throws TemplateInitException {
public void init(RuntimeServices rs, InternalContextAdapter context, Node node) {
super.init(rs, context, node);
final int n = node.jjtGetNumChildren() - 1;
for (int i = 1; i < n; i++) {
Expand Down Expand Up @@ -91,7 +88,7 @@ public void init(RuntimeServices rs, InternalContextAdapter context, Node node)

@Override
public boolean render(InternalContextAdapter context, Writer writer, Node node)
throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
throws IOException {

Object listObject = node.jjtGetChild(0).value(context);

Expand Down Expand Up @@ -254,7 +251,7 @@ protected NullHolderContext(String key, InternalContextAdapter context) {
}

@Override
public Object get(String key) throws MethodInvocationException {
public Object get(String key) {
return (this.active && this.loopVariableKey.equals(key))
? null
: super.get(key);
Expand All @@ -270,12 +267,7 @@ public Object put(String key, Object value) {
}

@Override
public Object localPut(final String key, final Object value) {
return put(key, value);
}

@Override
public Object remove(Object key) {
public Object remove(String key) {
if (this.loopVariableKey.equals(key)) {
this.active = false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,7 +45,7 @@ public SQLScriptSource(Configuration newConfiguration, String script, Class<?> p
@Override
public BoundSql getBoundSql(Object parameterObject) {

final Map<String, Object> context = new HashMap<String, Object>();
final Map<String, Object> context = new HashMap<>();
final ParameterMappingCollector pmc = new ParameterMappingCollector(this.parameterMappingSources, context, this.configuration);

context.put(DATABASE_ID_KEY, this.configuration.getDatabaseId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -18,9 +18,6 @@
import java.io.IOException;
import java.io.StringWriter;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.parser.node.ASTBlock;
import org.apache.velocity.runtime.parser.node.Node;

Expand All @@ -32,7 +29,7 @@ public String getName() {
}

@Override
protected Params getParams(InternalContextAdapter context, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
protected Params getParams(InternalContextAdapter context, Node node) throws IOException {
final Params params = new Params();
params.setPrefix("SET");
params.setSuffixOverrides(",");
Expand Down
15 changes: 6 additions & 9 deletions src/main/java/org/mybatis/scripting/velocity/TrimDirective.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,9 +20,6 @@
import java.io.Writer;
import java.util.Locale;
import org.apache.velocity.context.InternalContextAdapter;
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
import org.apache.velocity.runtime.directive.Directive;
import org.apache.velocity.runtime.parser.node.ASTBlock;
import org.apache.velocity.runtime.parser.node.Node;
Expand All @@ -40,15 +37,15 @@ public final int getType() {
}

@Override
public final boolean render(InternalContextAdapter ica, Writer writer, Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
public final boolean render(InternalContextAdapter ica, Writer writer, Node node) throws IOException {
Params p = getParams(ica, node);
if (p == null) {
return false;
}
return render(p, writer);
}

public boolean render(final Params params, final Writer writer) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
public boolean render(final Params params, final Writer writer) throws IOException {
int leftIndex = 0;
int rightIndex = params.maxBody;
if (rightIndex == 0) {
Expand Down Expand Up @@ -93,9 +90,9 @@ protected static final class Params {

String suffix = "";

FastLinkedList<String> prefixOverrides = new FastLinkedList<String>();
FastLinkedList<String> prefixOverrides = new FastLinkedList<>();

FastLinkedList<String> suffixOverrides = new FastLinkedList<String>();
FastLinkedList<String> suffixOverrides = new FastLinkedList<>();

String body = "";

Expand Down Expand Up @@ -153,7 +150,7 @@ public void setSuffix(String value) {

}

protected Params getParams(final InternalContextAdapter context, final Node node) throws IOException, ResourceNotFoundException, ParseErrorException, MethodInvocationException {
protected Params getParams(final InternalContextAdapter context, final Node node) throws IOException {
final Params params = new Params();
final int nodes = node.jjtGetNumChildren();
for (int i = 0; i < nodes; i++) {
Expand Down
Loading