Skip to content

Commit 6d21919

Browse files
authored
Add files via upload
1 parent 823ebe7 commit 6d21919

File tree

8 files changed

+1398
-0
lines changed

8 files changed

+1398
-0
lines changed

sync/db/mysql/AttributeMap.java

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package sync.db.mysql;
26+
27+
/**
28+
* An object of this class maps an attribute of the source table to an attribute
29+
* of the destination table.
30+
* @author Arvind Sasikumar
31+
*/
32+
public class AttributeMap {
33+
34+
private final String sourceAttribute;
35+
private final String destinationAttribute;
36+
37+
private final AttributeType type;
38+
39+
/**
40+
* Create a new attribute map using this constructor.
41+
* The sourceAttribute and destinationAttribute parameters refer to the
42+
* source and destination attribute names respectively that are to be mapped
43+
* as found in their respective tables. The type parameter indicates whether
44+
* the datatype of the attributes to be mapped is of form
45+
* {@link sync.db.mysql.AttributeType#STRING} or
46+
* {@link sync.db.mysql.AttributeType#NUMERICAL}.
47+
* @param sourceAttribute attribute name in the source table
48+
* @param destinationAttribute corresponding attribute name in the
49+
* destination table
50+
* @param type specifies whether the attribute is of type
51+
* {@link sync.db.mysql.AttributeType#STRING} or
52+
* {@link sync.db.mysql.AttributeType#NUMERICAL},
53+
* as defined in the enum {@link sync.db.mysql.AttributeType}.
54+
* @see sync.db.mysql.AttributeType
55+
* @see sync.db.mysql.AttributeType#STRING
56+
* @see sync.db.mysql.AttributeType#NUMERICAL
57+
*/
58+
public AttributeMap(String sourceAttribute, String destinationAttribute,
59+
AttributeType type){
60+
61+
this.sourceAttribute = sourceAttribute;
62+
this.destinationAttribute = destinationAttribute;
63+
this.type = type;
64+
}
65+
66+
/**
67+
* Gets the attribute name of the source table in the current attribute
68+
* mapping.
69+
* @return attribute name of the source table in the current attribute
70+
* mapping
71+
*/
72+
public String getSourceAttribute(){
73+
74+
return sourceAttribute;
75+
}
76+
77+
/**
78+
* Gets the attribute name of the destination table in the current attribute
79+
* mapping.
80+
* @return attribute name of the destination table in the current attribute
81+
* mapping
82+
*/
83+
public String getDestinationAttribute(){
84+
85+
return destinationAttribute;
86+
}
87+
88+
/**
89+
* Gets the attribute type of the current attribute mapping.
90+
* @return type of the current attribute mapping, as defined by the enum
91+
* {@link sync.db.mysql.AttributeType}.
92+
* @see sync.db.mysql.AttributeType
93+
* @see sync.db.mysql.AttributeType#STRING
94+
* @see sync.db.mysql.AttributeType#NUMERICAL
95+
*/
96+
public AttributeType getType(){
97+
98+
return type;
99+
}
100+
}

sync/db/mysql/AttributeType.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* The MIT License
3+
*
4+
* Copyright 2017 Arvind Sasikumar.
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
package sync.db.mysql;
26+
27+
/**
28+
* Enum class that defines the type of attribute being mapped between two tables.
29+
* <p>
30+
* <b>STRING</b> type refers to all attributes that require them to be
31+
* surrounded with a '' or "" in a MySQL insert statement.
32+
* <b>NUMERICAL</b> type refers to all attributes that do not require them to
33+
* be surrounded with a '' or "" in a MySQL insert statement.
34+
* @author Arvind Sasikumar
35+
*/
36+
public enum AttributeType {
37+
38+
STRING, NUMERICAL
39+
}

0 commit comments

Comments
 (0)