Commit fdc560af fdc560af7769110b1afad4247fcab7538ceb7434 by root

save

1 parent f660e192
1 <?xml version="1.0" encoding="UTF-8"?>
2 <classpath>
3 <classpathentry kind="src" output="target/classes" path="src/main/java">
4 <attributes>
5 <attribute name="optional" value="true"/>
6 <attribute name="maven.pomderived" value="true"/>
7 </attributes>
8 </classpathentry>
9 <classpathentry kind="src" output="target/test-classes" path="src/test/java">
10 <attributes>
11 <attribute name="optional" value="true"/>
12 <attribute name="maven.pomderived" value="true"/>
13 </attributes>
14 </classpathentry>
15 <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
16 <attributes>
17 <attribute name="maven.pomderived" value="true"/>
18 </attributes>
19 </classpathentry>
20 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
21 <attributes>
22 <attribute name="maven.pomderived" value="true"/>
23 </attributes>
24 </classpathentry>
25 <classpathentry kind="output" path="target/classes"/>
26 </classpath>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <projectDescription>
3 <name>XmlDbManager</name>
4 <comment></comment>
5 <projects>
6 </projects>
7 <buildSpec>
8 <buildCommand>
9 <name>org.eclipse.jdt.core.javabuilder</name>
10 <arguments>
11 </arguments>
12 </buildCommand>
13 <buildCommand>
14 <name>org.eclipse.m2e.core.maven2Builder</name>
15 <arguments>
16 </arguments>
17 </buildCommand>
18 </buildSpec>
19 <natures>
20 <nature>org.eclipse.jdt.core.javanature</nature>
21 <nature>org.eclipse.m2e.core.maven2Nature</nature>
22 </natures>
23 </projectDescription>
1 eclipse.preferences.version=1
2 encoding//src/main/java=UTF-8
3 encoding//src/test/java=UTF-8
4 encoding/<project>=UTF-8
1 eclipse.preferences.version=1
2 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
3 org.eclipse.jdt.core.compiler.compliance=1.7
4 org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5 org.eclipse.jdt.core.compiler.source=1.7
1 activeProfiles=
2 eclipse.preferences.version=1
3 resolveWorkspaceProjects=true
4 version=1
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 <modelVersion>4.0.0</modelVersion>
4
5 <groupId>org.emercit</groupId>
6 <artifactId>XmlDbManager</artifactId>
7 <version>0.0.1-SNAPSHOT</version>
8 <packaging>jar</packaging>
9
10 <name>XmlDbManager</name>
11 <url>http://maven.apache.org</url>
12
13 <properties>
14 <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
15 </properties>
16
17
18 <build>
19 <plugins>
20 <plugin>
21 <groupId>org.apache.maven.plugins</groupId>
22 <artifactId>maven-compiler-plugin</artifactId>
23 <configuration>
24 <source>1.7</source>
25 <target>1.7</target>
26 <showDeprecation>true</showDeprecation>
27 <showWarnings>true</showWarnings>
28 <executable>${env.JAVA_HOME_7}/bin/javac</executable>
29 <fork>true</fork>
30 </configuration>
31 </plugin>
32 </plugins>
33 </build>
34
35
36
37
38
39
40 <dependencies>
41 <dependency>
42 <groupId>junit</groupId>
43 <artifactId>junit</artifactId>
44 <version>3.8.1</version>
45 <scope>test</scope>
46 </dependency>
47
48 <dependency>
49 <groupId>org.emercit</groupId>
50 <artifactId>projecttools</artifactId>
51 <version>1.0</version>
52 </dependency>
53
54 </dependencies>
55
56
57
58
59 <repositories>
60 <!--other repositories if any-->
61 <repository>
62 <id>project.local</id>
63 <name>project</name>
64 <url>file:/root/git/hardwareconfig/DevTools/repo</url>
65 </repository>
66 </repositories>
67
68
69
70
71
72
73
74
75 </project>
1 package org.emercit.xmldbmanager;
2
3
4 public class App
5 {
6 public static void main( String[] args )
7 {
8
9 }
10 }
1 package org.emercit.xmldbmanager.service;
2
3 import java.beans.XMLDecoder;
4 import java.beans.XMLEncoder;
5 import java.io.BufferedInputStream;
6 import java.io.BufferedOutputStream;
7 import java.io.FileInputStream;
8 import java.io.FileOutputStream;
9
10 import org.emercit.projecttools.constants.Paths;
11
12 public class Db implements IDb {
13
14
15 private String pathfile=null;
16
17
18 public Db(String path) {
19 this.pathfile=path;
20 }
21
22 /*
23 * Создает или перезаписывает сущетсвующий файл
24 * @see org.emercit.xmldbmanager.service.IDb#create(java.lang.Object)
25 */
26 public boolean create(Object o) {
27
28 boolean result=true;
29 try {
30 FileOutputStream fos = new FileOutputStream(pathfile);
31 BufferedOutputStream bos = new BufferedOutputStream(fos);
32 XMLEncoder xmlEncoder = new XMLEncoder(bos);
33 xmlEncoder.writeObject(o);
34 xmlEncoder.close();
35 }catch(Exception e) {
36 result=false;
37 }
38 return result;
39
40 }
41
42 /*
43 * Возвращает объект из фалй
44 */
45 public Object select() {
46
47 try {
48 XMLDecoder d = new XMLDecoder(
49 new BufferedInputStream(
50 new FileInputStream(pathfile)));
51 Object result=(Object)d.readObject();
52 d.close();
53
54 return result;
55 }catch(Exception e) {
56
57 return null;
58 }
59
60
61 }
62
63
64
65
66 }
1 package org.emercit.xmldbmanager.service;
2
3 public interface IDb {
4
5 public boolean create(Object obj);
6
7 public Object select();
8
9 }
1 package org.emercit.XmlDbManager;
2
3 import junit.framework.Test;
4 import junit.framework.TestCase;
5 import junit.framework.TestSuite;
6
7 /**
8 * Unit test for simple App.
9 */
10 public class AppTest
11 extends TestCase
12 {
13 /**
14 * Create the test case
15 *
16 * @param testName name of the test case
17 */
18 public AppTest( String testName )
19 {
20 super( testName );
21 }
22
23 /**
24 * @return the suite of tests being tested
25 */
26 public static Test suite()
27 {
28 return new TestSuite( AppTest.class );
29 }
30
31 /**
32 * Rigourous Test :-)
33 */
34 public void testApp()
35 {
36 assertTrue( true );
37 }
38 }