diff --git a/group19/527220084/xukai_coding/.gitignore b/group19/527220084/xukai_coding/.gitignore new file mode 100644 index 0000000000..ba13ec60db --- /dev/null +++ b/group19/527220084/xukai_coding/.gitignore @@ -0,0 +1,8 @@ +*target +*.classpath +*.project +*.settings +*iml +.idea +*gen-* +rebel.xml \ No newline at end of file diff --git a/group19/527220084/xukai_coding/coding-common/pom.xml b/group19/527220084/xukai_coding/coding-common/pom.xml new file mode 100644 index 0000000000..ab70ddd636 --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/pom.xml @@ -0,0 +1,107 @@ + + + + xukai.coding + org.xukai.coding + 1.0-SNAPSHOT + + 4.0.0 + jar + coding.common + + + + junit + junit + + + org.freemarker + freemarker + + + commons-beanutils + commons-beanutils + 1.8.0 + + + org.apache.commons + commons-compress + 1.8.1 + + + commons-lang + commons-lang + + + commons-logging + commons-logging + 1.2 + + + org.apache.commons + commons-lang3 + + + commons-io + commons-io + + + com.google.guava + guava + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-log4j12 + + + org.slf4j + jcl-over-slf4j + + + + + + + + + com.google.code.findbugs + jsr305 + 3.0.1 + + + cglib + cglib + + + joda-time + joda-time + + + + + + + + + + + javax.servlet + javax.servlet-api + + + org.springframework + spring-web + + + com.alibaba + fastjson + + + + \ No newline at end of file diff --git a/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/ArrayList.java b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/ArrayList.java new file mode 100644 index 0000000000..0a8601c8ee --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/ArrayList.java @@ -0,0 +1,102 @@ +package org.xukai.common; + + + +public class ArrayList implements List { + + private int size = 0; + + private static final int DEFAULT_CAPICITY = 10; + + public ArrayList() { + elementData = new Object[DEFAULT_CAPICITY]; + } + + public ArrayList(int size) { + elementData = new Object[size]; + } + + private Object[] elementData ; + + public void add(Object o){ + elementData[size] = o; + size++; + } + public void add(int index, Object o){ + if (index < 0 || index > size ) { + throw new ArrayIndexOutOfBoundsException(); + } else { + if (isNeedResize(index)) { + elementData = grown(elementData, Math.max(elementData.length << 1, index + 1)); + } + if(index < size){ + System.arraycopy(elementData,index,elementData,index+1,size-index); + } + elementData[index] = o; + } + size++; + } + + + + public Object get(int index){ + if (index > size-1 || index < 0) { + throw new ArrayIndexOutOfBoundsException(); + } + return elementData[index]; + } + + public Object remove(int index){ + if (index > size-1 || index < 0) { + throw new ArrayIndexOutOfBoundsException(); + } + Object result = elementData[index]; + size--; + System.arraycopy(elementData,index+1,elementData,index,size-index); + return result; + } + + public int size(){ + return size; + } + + public Iterator iterator(){ + return new ArrayListIterator(); + } + + class ArrayListIterator implements Iterator { + + private int pos = -1; + + @Override + public boolean hasNext() { + return pos < size - 1; + } + + @Override + public Object next() { + pos++; + return elementData[pos]; + } + } + + public void display(){ + System.out.print("["); + Iterator iterator = iterator(); + while (iterator.hasNext()){ + System.out.print(" " + iterator.next()); + } + System.out.print(" ]"); + } + + private boolean isNeedResize(int index){ + return index > elementData.length-1 || size > elementData.length-1; + } + + private Object[] grown(Object[] src,int capacity){ + Object[] des = new Object[capacity]; + System.arraycopy(elementData,0,des,0,elementData.length); + return des; + } + +} diff --git a/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/BinaryTreeNode.java b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/BinaryTreeNode.java new file mode 100644 index 0000000000..2ff876cac5 --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/BinaryTreeNode.java @@ -0,0 +1,53 @@ +package org.xukai.common; + +public class BinaryTreeNode { + + private Object data; + private BinaryTreeNode left; + private BinaryTreeNode right; + + public Object getData() { + return data; + } + public void setData(Object data) { + this.data = data; + } + public BinaryTreeNode getLeft() { + return left; + } + public void setLeft(BinaryTreeNode left) { + this.left = left; + } + public BinaryTreeNode getRight() { + return right; + } + public void setRight(BinaryTreeNode right) { + this.right = right; + } + + public BinaryTreeNode insert(Comparable o){ + if (data == null) { + data = o; + return this; + } else { + BinaryTreeNode node = new BinaryTreeNode(); + node.data = o; + if (o.compareTo(data) < 0) { + if (left == null) { + left = node; + return node; + } else { + return left.insert(o); + } + } else { + if (right == null) { + right = node; + return node; + } else { + return right.insert(o); + } + } + } + } + +} diff --git a/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Iterator.java b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Iterator.java new file mode 100644 index 0000000000..d81ade6ba5 --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Iterator.java @@ -0,0 +1,7 @@ +package org.xukai.common; + +public interface Iterator { + public boolean hasNext(); + public Object next(); + +} diff --git a/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/LinkedList.java b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/LinkedList.java new file mode 100644 index 0000000000..cb1585cecf --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/LinkedList.java @@ -0,0 +1,163 @@ +package org.xukai.common; + +public class LinkedList implements List { + + private Node head; + + private int size = 0; + + public void add(Object o){ + Node node = new Node(); + node.data = o; + if (head == null) { + head = node; + } else { + Node next = head.next; + if (next == null) { + head.next = node; + } else { + while (next.next != null){ + next = next.next; + } + next.next = node; + } + } + size++; + } + + public void add(int index , Object o){ + if (index < 0 || index > size ) { + throw new ArrayIndexOutOfBoundsException(); + } else { + size++; + Node node = new Node(); + node.data = o; + if (index == 0) { + node.next = head; + head = node; + return; + } + int pos = 1; + Node next = head; + //index 2 + while(index > pos){ + next = next.next; + pos++; + } + node.next = next.next; + next.next = node; + } + } + public Object get(int index){ + if (index < 0 || index > size ) { + throw new ArrayIndexOutOfBoundsException(); + } else { + if (index == 0) { + return head.data; + } + int pos = 1; + Node next = head; + //index 2 + while(index > pos){ + next = next.next; + pos++; + } + return next.data; + } + } + + public Object remove(int index){ + if (index < 0 || index > size - 1 ) { + throw new ArrayIndexOutOfBoundsException(); + } else { + if (index == 0) { + Node result = head; + head = head.next; + return result.data; + } + int pos = 1; + Node next = head; + //index 1 + while(index > pos){ + next = next.next; + pos++; + } + Node result = next.next; + next.next = next.next.next; + size--; + return result.data; + } + } + + public int size(){ + return size; + } + + public void addFirst(Object o){ + Node node = new Node(); + node.data = o; + node.next = head; + head = node; + size++; + } + + public void addLast(Object o){ + add(o); + } + + public Object removeFirst(){ + Node result = head; + head = head.next; + size--; + return result.data; + } + + public Object removeLast(){ + return remove(size-1); + } + + public Iterator iterator(){ + return new LinkedListIterator(); + } + + class LinkedListIterator implements Iterator { + + private Node currentNode ; + + @Override + public boolean hasNext() { + if (currentNode == null) { + if (head != null) { + return true; + } else { + return false; + } + } + return currentNode.next != null; + } + + @Override + public Object next() { + if (currentNode == null) { + currentNode = head; + return currentNode.data; + } + currentNode = currentNode.next; + return currentNode.data; + } + } + + public void display(){ + System.out.print("["); + Iterator iterator = iterator(); + while (iterator.hasNext()){ + System.out.print(" " + iterator.next()); + } + System.out.print(" ]"); + } + + private static class Node{ + Object data; + Node next; + } +} diff --git a/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/List.java b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/List.java new file mode 100644 index 0000000000..ab5dcb4178 --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/List.java @@ -0,0 +1,9 @@ +package org.xukai.common; + +public interface List { + public void add(Object o); + public void add(int index, Object o); + public Object get(int index); + public Object remove(int index); + public int size(); +} diff --git a/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Queue.java b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Queue.java new file mode 100644 index 0000000000..ad77cee9ae --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Queue.java @@ -0,0 +1,27 @@ +package org.xukai.common; + +import java.util.NoSuchElementException; + +public class Queue { + + private LinkedList elementData = new LinkedList(); + + public void enQueue(Object o){ + elementData.add(o); + } + + public Object deQueue(){ + if (isEmpty()) { + throw new NoSuchElementException(); + } + return elementData.removeFirst(); + } + + public boolean isEmpty(){ + return elementData.size() == 0; + } + + public int size(){ + return elementData.size(); + } +} diff --git a/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Stack.java b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Stack.java new file mode 100644 index 0000000000..de705e1fec --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/main/java/org/xukai/common/Stack.java @@ -0,0 +1,34 @@ +package org.xukai.common; + +import java.util.EmptyStackException; + +public class Stack { + + private ArrayList elementData = new ArrayList(); + + public void push(Object o){ + elementData.add(o); + } + + public Object pop(){ + if (isEmpty()) { + throw new EmptyStackException(); + } + return elementData.remove(elementData.size()-1); + } + + public Object peek(){ + if (isEmpty()) { + throw new EmptyStackException(); + } + return elementData.get(elementData.size()-1); + } + + public boolean isEmpty(){ + return elementData.size() == 0; + } + + public int size(){ + return elementData.size(); + } +} diff --git a/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/ArrayListTest.java b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/ArrayListTest.java new file mode 100644 index 0000000000..b14feb5ab4 --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/ArrayListTest.java @@ -0,0 +1,70 @@ +package org.xukai.common; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author xukai + * @desc + * @date 2017-02-20-下午 2:02 + */ +public class ArrayListTest { + + @Test + public void testAdd() throws Exception { + ArrayList list = new ArrayList(); + list.add("0"); + list.add("1"); + list.add("2"); + list.add("3"); + list.add("4"); + Assert.assertTrue(list.size() == 5); + list.add(0,"3"); + Assert.assertTrue(list.get(0).equals("3")); + Assert.assertTrue(list.size() == 6); + list.remove(5); + Assert.assertTrue(list.size() == 5); + list.display(); + } + + @Test + public void testAdd1() throws Exception { + + } + + @Test + public void testGet() throws Exception { + + } + + @Test + public void testRemove() throws Exception { + + } + + @Test + public void testSize() throws Exception { + + } + + @Test + public void testIterator() throws Exception { + ArrayList list = new ArrayList(); + list.add("0"); + list.add("1"); + list.add("2"); + list.add("3"); + list.add("4"); + Iterator iterator = list.iterator(); + while (iterator.hasNext()){ + System.out.println(iterator.next()); + } + } + + @Test + public void testDisplay() throws Exception { + + } +} \ No newline at end of file diff --git a/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/BinaryTreeNodeTest.java b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/BinaryTreeNodeTest.java new file mode 100644 index 0000000000..cc85baaa97 --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/BinaryTreeNodeTest.java @@ -0,0 +1,28 @@ +package org.xukai.common; + +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author xukai + * @desc + * @date 2017-02-20-下午 5:02 + */ +public class BinaryTreeNodeTest { + + + @Test + public void testInsert() throws Exception { + BinaryTreeNode node = new BinaryTreeNode(); + node.insert(5); + node.insert(9); + node.insert(3); + node.insert(7); + node.insert(2); + node.insert(8); + node.insert(4); + node.insert(6); + node.insert(1); + } +} \ No newline at end of file diff --git a/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/LinkedListTest.java b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/LinkedListTest.java new file mode 100644 index 0000000000..d31e3a70ec --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/LinkedListTest.java @@ -0,0 +1,91 @@ +package org.xukai.common; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author xukai + * @desc + * @date 2017-02-20-下午 3:54 + */ +public class LinkedListTest { + + @Test + public void testAdd() throws Exception { + LinkedList list = new LinkedList(); + list.add("0"); + list.add("1"); + list.add("2"); + list.add("3"); + list.add("4"); + Assert.assertTrue(list.size() == 5); + list.add(0,"000"); + Assert.assertTrue( (list.get(0)).equals("000")); + Assert.assertTrue(list.size() == 6); + list.addFirst("111"); + Assert.assertTrue(list.get(0).equals("111")); + list.remove(5); + Assert.assertTrue(list.size() == 6); + list.addLast("111"); + Assert.assertTrue(list.size() == 7); + list.removeFirst(); + Assert.assertTrue(list.size() == 6); + list.removeLast(); + Assert.assertTrue(list.size() == 5); + list.remove(4); + Assert.assertTrue(list.size() == 4); + list.display(); + } + + @Test + public void testAdd1() throws Exception { + + } + + @Test + public void testGet() throws Exception { + + } + + @Test + public void testRemove() throws Exception { + + } + + @Test + public void testSize() throws Exception { + + } + + @Test + public void testAddFirst() throws Exception { + + } + + @Test + public void testAddLast() throws Exception { + + } + + @Test + public void testRemoveFirst() throws Exception { + + } + + @Test + public void testRemoveLast() throws Exception { + + } + + @Test + public void testIterator() throws Exception { + + } + + @Test + public void testDisplay() throws Exception { + + } +} \ No newline at end of file diff --git a/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/QueueTest.java b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/QueueTest.java new file mode 100644 index 0000000000..fa1a6e9f2c --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/QueueTest.java @@ -0,0 +1,46 @@ +package org.xukai.common; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author xukai + * @desc + * @date 2017-02-20-下午 4:36 + */ +public class QueueTest { + + @Test + public void testEnQueue() throws Exception { + Queue queue = new Queue(); + Assert.assertTrue(queue.isEmpty()); + queue.enQueue("0"); + queue.enQueue("1"); + queue.enQueue("2"); + queue.enQueue("3"); + Assert.assertTrue(!queue.isEmpty()); + Assert.assertTrue(queue.deQueue().equals("0")); + Assert.assertTrue(queue.deQueue().equals("1")); + Assert.assertTrue(queue.size() == 2); + queue.deQueue(); + queue.deQueue(); + Assert.assertTrue(queue.isEmpty()); + } + + @Test + public void testDeQueue() throws Exception { + + } + + @Test + public void testIsEmpty() throws Exception { + + } + + @Test + public void testSize() throws Exception { + + } +} \ No newline at end of file diff --git a/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/StackTest.java b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/StackTest.java new file mode 100644 index 0000000000..69fc9dee6e --- /dev/null +++ b/group19/527220084/xukai_coding/coding-common/src/test/java/org/xukai/common/StackTest.java @@ -0,0 +1,52 @@ +package org.xukai.common; + +import org.junit.Assert; +import org.junit.Test; + +import static org.junit.Assert.*; + +/** + * @author xukai + * @desc + * @date 2017-02-20-下午 4:20 + */ +public class StackTest { + + @Test + public void testPush() throws Exception { + Stack stack = new Stack(); + Assert.assertTrue(stack.isEmpty()); + stack.push("0"); + stack.push("1"); + stack.push("2"); + stack.push("3"); + Assert.assertTrue(!stack.isEmpty()); + Assert.assertTrue(stack.peek().equals("3")); + Assert.assertTrue(stack.pop().equals("3")); + Assert.assertTrue(stack.size() == 3); + stack.pop(); + stack.pop(); + stack.pop(); + Assert.assertTrue(stack.isEmpty()); + } + + @Test + public void testPop() throws Exception { + + } + + @Test + public void testPeek() throws Exception { + + } + + @Test + public void testIsEmpty() throws Exception { + + } + + @Test + public void testSize() throws Exception { + + } +} \ No newline at end of file diff --git a/group19/527220084/xukai_coding/pom.xml b/group19/527220084/xukai_coding/pom.xml new file mode 100644 index 0000000000..f8e396ae46 --- /dev/null +++ b/group19/527220084/xukai_coding/pom.xml @@ -0,0 +1,422 @@ + + + 4.0.0 + + org.xukai.coding + xukai.coding + pom + 1.0-SNAPSHOT + + coding-common + + + + UTF-8 + 3.15.0-GA + 3.7.0.Final + 4.1.6.RELEASE + 2.6 + 3.4 + 1.7 + 2.3.21 + 3.2.8 + 1.2.2 + 5.1.29 + + 1.3 + 17.0 + 1.0.11 + 4.11 + 2.1.1 + 2.1.2 + 3.4.5 + 1.1.38 + 2.2.2 + 1.2-GUAHAO + 1.1.1 + 2.3.2 + 2.4.4 + 1.9 + 2.9.6 + 1.8 + 10.2.0.4.0 + 2.2.1 + 1.7.2 + 1.3 + 1.6.6 + 1.6.6 + 3.1 + 4.0 + 2.8.0 + + + + + + + org.slf4j + jcl-over-slf4j + ${jcl-over-slf4j.version} + + + + cglib + cglib + ${cglib.version} + + + org.quartz-scheduler + quartz + ${quartz.version} + + + org.apache.zookeeper + zookeeper + ${zookeeper.version} + + + com.github.sgroschupf + zkclient + 0.1 + + + org.springframework + spring-org.xukai.core.org.xukai.core.aop + ${spring.version} + + + org.springframework + spring-aspects + ${spring.version} + + + org.springframework + spring-jdbc + ${spring.version} + + + org.springframework + spring-orm + ${spring.version} + + + org.springframework + spring-websocket + ${spring.version} + + + org.springframework + spring-messaging + ${spring.version} + + + org.springframework + spring-aop + ${spring.version} + + + org.springframework + spring-core + ${spring.version} + + + org.springframework + spring-webmvc + ${spring.version} + + + org.springframework + spring-web + ${spring.version} + + + org.springframework + spring-context-support + ${spring.version} + + + org.springframework + spring-context + ${spring.version} + + + org.springframework + spring-tx + ${spring.version} + + + org.springframework + spring-beans + ${spring.version} + + + org.springframework + spring-expression + ${spring.version} + + + + + + + + org.springframework + spring-oxm + ${spring.version} + + + org.springframework + spring-test + ${spring.version} + + + org.aspectj + aspectjweaver + ${aspectj.version} + + + commons-fileupload + commons-fileupload + ${commons-fileupload.version} + + + com.google.guava + guava + ${guava.version} + + + org.mybatis + mybatis-spring + ${mybatis.spring.version} + + + org.slf4j + slf4j-log4j12 + ${slf4j-log4j12.version} + + + org.mybatis + mybatis + ${mybatis.version} + + + + mysql + mysql-connector-java + ${mysql.java.version} + + + com.oracle + ojdbc14 + ${oracle.version} + + + org.apache.velocity + velocity + ${velocity.version} + + + org.freemarker + freemarker + ${freemarker.version} + + + + com.fasterxml.jackson.core + jackson-databind + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-annotations + ${jackson.version} + + + com.fasterxml.jackson.core + jackson-core + ${jackson.version} + + + commons-lang + commons-lang + ${commons.lang.version} + + + org.apache.commons + commons-lang3 + ${commons.lang3.version} + + + commons-dbcp + commons-dbcp + ${commons.dbcp.version} + + + com.google.code.kaptcha + kaptcha + ${kaptcha.version} + + + com.alibaba + druid + ${druid.version} + + + org.slf4j + slf4j-api + 1.7.7 + + + org.apache.velocity + velocity-tools + 2.0 + + + log4j + log4j + 1.2.16 + + + dom4j + dom4j + 1.6.1 + + + javax.servlet + servlet-api + 2.5 + + + commons-codec + commons-codec + ${commons.codec} + + + commons-io + commons-io + 1.4 + + + javax.servlet + javax.servlet-api + 3.0.1 + + + junit + junit + ${junit.version} + + + org.apache.maven.plugins + maven-resources-plugin + 2.4.3 + + + com.alibaba + fastjson + ${fastjson.version} + + + com.greenline.common + greenline-common-util + ${greenline.common.util} + + + joda-time + joda-time + ${v.joda.time.version} + + + + javax.servlet + jsp-api + 2.0 + + + org.apache.commons + commons-collections4 + ${commons-collections4.version} + + + + redis.clients + jedis + ${jedis.version}} + + + + + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + ${v.p.mvn.compiler} + + ${project.ud.jdk} + ${project.ud.jdk} + UTF-8 + + ${project.build.sourceDirectory} + + + + + org.apache.maven.plugins + maven-deploy-plugin + 2.8 + + true + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + utf-8 + utf-8 + + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.3 + + + attach-javadocs + + jar + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.18.1 + + true + + + + + + + \ No newline at end of file