code
stringlengths 67
466k
| docstring
stringlengths 1
13.2k
|
---|---|
public Set<String> rangeByLex(final LexRange lexRange) {
return doWithJedis(new JedisCallable<Set<String>>() {
@Override
public Set<String> call(Jedis jedis) {
if (lexRange.hasLimit()) {
return jedis.zrangeByLex(getKey(), lexRange.from(), lexRange.to(), lexRange.offset(), lexRange.count());
} else {
return jedis.zrangeByLex(getKey(), lexRange.from(), lexRange.to());
}
}
});
} | When all the elements in a sorted set are inserted with the same score, in order to force lexicographical
ordering, this command returns all the elements in the sorted set with a value in the given range.
If the elements in the sorted set have different scores, the returned elements are unspecified.
@param lexRange
@return the range of elements |
public Set<String> rangeByLexReverse(final LexRange lexRange) {
return doWithJedis(new JedisCallable<Set<String>>() {
@Override
public Set<String> call(Jedis jedis) {
if (lexRange.hasLimit()) {
return jedis.zrevrangeByLex(getKey(), lexRange.fromReverse(), lexRange.toReverse(), lexRange.offset(), lexRange.count());
} else {
return jedis.zrevrangeByLex(getKey(), lexRange.fromReverse(), lexRange.toReverse());
}
}
});
} | When all the elements in a sorted set are inserted with the same score, in order to force lexicographical
ordering, this command returns all the elements in the sorted set with a value in the given range.
@param lexRange
@return the range of elements |
public long removeRangeByLex(final LexRange lexRange) {
return doWithJedis(new JedisCallable<Long>() {
@Override
public Long call(Jedis jedis) {
return jedis.zremrangeByLex(getKey(), lexRange.from(), lexRange.to());
}
});
} | When all the elements in a sorted set are inserted with the same score, in order to force lexicographical
ordering, this command removes all elements in the sorted set between the lexicographical range specified.
@param lexRange
@return the number of elements removed. |
public Set<String> rangeByScore(final ScoreRange scoreRange) {
return doWithJedis(new JedisCallable<Set<String>>() {
@Override
public Set<String> call(Jedis jedis) {
if (scoreRange.hasLimit()) {
return jedis.zrangeByScore(getKey(), scoreRange.from(), scoreRange.to(), scoreRange.offset(), scoreRange.count());
} else {
return jedis.zrangeByScore(getKey(), scoreRange.from(), scoreRange.to());
}
}
});
} | Returns all the elements in the sorted set with a score in the given range.
The elements are considered to be ordered from low to high scores.
The elements having the same score are returned in lexicographical order (this follows from a property of the
sorted set implementation in Redis and does not involve further computation).
@param scoreRange
@return elements in the specified score range |
public Set<String> rangeByScoreReverse(final ScoreRange scoreRange) {
return doWithJedis(new JedisCallable<Set<String>>() {
@Override
public Set<String> call(Jedis jedis) {
if (scoreRange.hasLimit()) {
return jedis.zrevrangeByScore(getKey(), scoreRange.fromReverse(), scoreRange.toReverse(), scoreRange.offset(), scoreRange.count());
} else {
return jedis.zrevrangeByScore(getKey(), scoreRange.fromReverse(), scoreRange.toReverse());
}
}
});
} | Returns all the elements in the sorted set with a score in the given range.
In contrary to the default ordering of sorted sets, for this command the elements are considered to be ordered
from high to low scores.
The elements having the same score are returned in reverse lexicographical order.
@param scoreRange
@return elements in the specified score range |
public long removeRangeByScore(final ScoreRange scoreRange) {
return doWithJedis(new JedisCallable<Long>() {
@Override
public Long call(Jedis jedis) {
return jedis.zremrangeByScore(getKey(), scoreRange.from(), scoreRange.to());
}
});
} | Removes all elements in the sorted set with a score in the given range.
@param scoreRange
@return the number of elements removed. |
public void printPoints(PrintStream ps) {
for (int i = 0; i < numPoints; i++) {
Point3d pnt = pointBuffer[i].pnt;
ps.println(pnt.x + ", " + pnt.y + ", " + pnt.z + ",");
}
} | print all points to the print stream (very point a line)
@param ps
the print stream to write to |
public void build(double[] coords, int nump) throws IllegalArgumentException {
if (nump < 4) {
throw new IllegalArgumentException("Less than four input points specified");
}
if (coords.length / 3 < nump) {
throw new IllegalArgumentException("Coordinate array too small for specified number of points");
}
initBuffers(nump);
setPoints(coords, nump);
buildHull();
} | Constructs the convex hull of a set of points whose coordinates are given
by an array of doubles.
@param coords
x, y, and z coordinates of each input point. The length of
this array must be at least three times <code>nump</code>.
@param nump
number of input points
@throws IllegalArgumentException
the number of input points is less than four or greater than
1/3 the length of <code>coords</code>, or the points appear
to be coincident, colinear, or coplanar. |
public void build(Point3d[] points, int nump) throws IllegalArgumentException {
if (nump < 4) {
throw new IllegalArgumentException("Less than four input points specified");
}
if (points.length < nump) {
throw new IllegalArgumentException("Point array too small for specified number of points");
}
initBuffers(nump);
setPoints(points, nump);
buildHull();
} | Constructs the convex hull of a set of points.
@param points
input points
@param nump
number of input points
@throws IllegalArgumentException
the number of input points is less than four or greater then
the length of <code>points</code>, or the points appear to be
coincident, colinear, or coplanar. |
public void triangulate() {
double minArea = 1000 * charLength * DOUBLE_PREC;
newFaces.clear();
for (Iterator it = faces.iterator(); it.hasNext();) {
Face face = (Face) it.next();
if (face.mark == Face.VISIBLE) {
face.triangulate(newFaces, minArea);
// splitFace (face);
}
}
for (Face face = newFaces.first(); face != null; face = face.next) {
faces.add(face);
}
} | Triangulates any non-triangular hull faces. In some cases, due to
precision issues, the resulting triangles may be very thin or small, and
hence appear to be non-convex (this same limitation is present in <a
href=http://www.qhull.org>qhull</a>). |
protected void initBuffers(int nump) {
if (pointBuffer.length < nump) {
Vertex[] newBuffer = new Vertex[nump];
vertexPointIndices = new int[nump];
for (int i = 0; i < pointBuffer.length; i++) {
newBuffer[i] = pointBuffer[i];
}
for (int i = pointBuffer.length; i < nump; i++) {
newBuffer[i] = new Vertex();
}
pointBuffer = newBuffer;
}
faces.clear();
claimed.clear();
numFaces = 0;
numPoints = nump;
} | } |
protected void createInitialSimplex() throws IllegalArgumentException {
double max = 0;
int imax = 0;
for (int i = 0; i < 3; i++) {
double diff = maxVtxs[i].pnt.get(i) - minVtxs[i].pnt.get(i);
if (diff > max) {
max = diff;
imax = i;
}
}
if (max <= tolerance) {
throw new IllegalArgumentException("Input points appear to be coincident");
}
Vertex[] vtx = new Vertex[4];
// set first two vertices to be those with the greatest
// one dimensional separation
vtx[0] = maxVtxs[imax];
vtx[1] = minVtxs[imax];
// set third vertex to be the vertex farthest from
// the line between vtx0 and vtx1
Vector3d u01 = new Vector3d();
Vector3d diff02 = new Vector3d();
Vector3d nrml = new Vector3d();
Vector3d xprod = new Vector3d();
double maxSqr = 0;
u01.sub(vtx[1].pnt, vtx[0].pnt);
u01.normalize();
for (int i = 0; i < numPoints; i++) {
diff02.sub(pointBuffer[i].pnt, vtx[0].pnt);
xprod.cross(u01, diff02);
double lenSqr = xprod.normSquared();
if (lenSqr > maxSqr && pointBuffer[i] != vtx[0] && // paranoid
pointBuffer[i] != vtx[1]) {
maxSqr = lenSqr;
vtx[2] = pointBuffer[i];
nrml.set(xprod);
}
}
if (Math.sqrt(maxSqr) <= 100 * tolerance) {
throw new IllegalArgumentException("Input points appear to be colinear");
}
nrml.normalize();
double maxDist = 0;
double d0 = vtx[2].pnt.dot(nrml);
for (int i = 0; i < numPoints; i++) {
double dist = Math.abs(pointBuffer[i].pnt.dot(nrml) - d0);
if (dist > maxDist && pointBuffer[i] != vtx[0] && // paranoid
pointBuffer[i] != vtx[1] && pointBuffer[i] != vtx[2]) {
maxDist = dist;
vtx[3] = pointBuffer[i];
}
}
if (Math.abs(maxDist) <= 100 * tolerance) {
throw new IllegalArgumentException("Input points appear to be coplanar");
}
if (LOG.isDebugEnabled()) {
LOG.debug("initial vertices:");
LOG.debug(vtx[0].index + ": " + vtx[0].pnt);
LOG.debug(vtx[1].index + ": " + vtx[1].pnt);
LOG.debug(vtx[2].index + ": " + vtx[2].pnt);
LOG.debug(vtx[3].index + ": " + vtx[3].pnt);
}
Face[] tris = new Face[4];
if (vtx[3].pnt.dot(nrml) - d0 < 0) {
tris[0] = Face.createTriangle(vtx[0], vtx[1], vtx[2]);
tris[1] = Face.createTriangle(vtx[3], vtx[1], vtx[0]);
tris[2] = Face.createTriangle(vtx[3], vtx[2], vtx[1]);
tris[3] = Face.createTriangle(vtx[3], vtx[0], vtx[2]);
for (int i = 0; i < 3; i++) {
int k = (i + 1) % 3;
tris[i + 1].getEdge(1).setOpposite(tris[k + 1].getEdge(0));
tris[i + 1].getEdge(2).setOpposite(tris[0].getEdge(k));
}
} else {
tris[0] = Face.createTriangle(vtx[0], vtx[2], vtx[1]);
tris[1] = Face.createTriangle(vtx[3], vtx[0], vtx[1]);
tris[2] = Face.createTriangle(vtx[3], vtx[1], vtx[2]);
tris[3] = Face.createTriangle(vtx[3], vtx[2], vtx[0]);
for (int i = 0; i < 3; i++) {
int k = (i + 1) % 3;
tris[i + 1].getEdge(0).setOpposite(tris[k + 1].getEdge(1));
tris[i + 1].getEdge(2).setOpposite(tris[0].getEdge((3 - i) % 3));
}
}
for (int i = 0; i < 4; i++) {
faces.add(tris[i]);
}
for (int i = 0; i < numPoints; i++) {
Vertex v = pointBuffer[i];
if (v == vtx[0] || v == vtx[1] || v == vtx[2] || v == vtx[3]) {
continue;
}
maxDist = tolerance;
Face maxFace = null;
for (int k = 0; k < 4; k++) {
double dist = tris[k].distanceToPlane(v.pnt);
if (dist > maxDist) {
maxFace = tris[k];
maxDist = dist;
}
}
if (maxFace != null) {
addPointToFace(v, maxFace);
}
}
} | Creates the initial simplex from which the hull will be built. |
public Point3d[] getVertices() {
Point3d[] vtxs = new Point3d[numVertices];
for (int i = 0; i < numVertices; i++) {
vtxs[i] = pointBuffer[vertexPointIndices[i]].pnt;
}
return vtxs;
} | Returns the vertex points in this hull.
@return array of vertex points
@see QuickHull3D#getVertices(double[])
@see QuickHull3D#getFaces() |
public int getVertices(double[] coords) {
for (int i = 0; i < numVertices; i++) {
Point3d pnt = pointBuffer[vertexPointIndices[i]].pnt;
coords[i * 3 + 0] = pnt.x;
coords[i * 3 + 1] = pnt.y;
coords[i * 3 + 2] = pnt.z;
}
return numVertices;
} | Returns the coordinates of the vertex points of this hull.
@param coords
returns the x, y, z coordinates of each vertex. This length of
this array must be at least three times the number of
vertices.
@return the number of vertices
@see QuickHull3D#getVertices()
@see QuickHull3D#getFaces() |
public int[] getVertexPointIndices() {
int[] indices = new int[numVertices];
for (int i = 0; i < numVertices; i++) {
indices[i] = vertexPointIndices[i];
}
return indices;
} | Returns an array specifing the index of each hull vertex with respect to
the original input points.
@return vertex indices with respect to the original points |
public int[][] getFaces(int indexFlags) {
int[][] allFaces = new int[faces.size()][];
int k = 0;
for (Iterator it = faces.iterator(); it.hasNext();) {
Face face = (Face) it.next();
allFaces[k] = new int[face.numVertices()];
getFaceIndices(allFaces[k], face, indexFlags);
k++;
}
return allFaces;
} | Returns the faces associated with this hull.
<p>
Each face is represented by an integer array which gives the indices of
the vertices. By default, these indices are numbered with respect to the
hull vertices (as opposed to the input points), are zero-based, and are
arranged counter-clockwise. However, this can be changed by setting
{@link #POINT_RELATIVE POINT_RELATIVE}, {@link #INDEXED_FROM_ONE
INDEXED_FROM_ONE}, or {@link #CLOCKWISE CLOCKWISE} in the indexFlags
parameter.
@param indexFlags
specifies index characteristics (0 results in the default)
@return array of integer arrays, giving the vertex indices for each face.
@see QuickHull3D#getVertices() |
public void print(PrintStream ps, int indexFlags) {
if ((indexFlags & INDEXED_FROM_ZERO) == 0) {
indexFlags |= INDEXED_FROM_ONE;
}
for (int i = 0; i < numVertices; i++) {
Point3d pnt = pointBuffer[vertexPointIndices[i]].pnt;
ps.println("v " + pnt.x + " " + pnt.y + " " + pnt.z);
}
for (Iterator fi = faces.iterator(); fi.hasNext();) {
Face face = (Face) fi.next();
int[] indices = new int[face.numVertices()];
getFaceIndices(indices, face, indexFlags);
ps.print("f");
for (int k = 0; k < indices.length; k++) {
ps.print(" " + indices[k]);
}
ps.println("");
}
} | Prints the vertices and faces of this hull to the stream ps.
<p>
This is done using the Alias Wavefront .obj file format, with the
vertices printed first (each preceding by the letter <code>v</code>),
followed by the vertex indices for each face (each preceded by the letter
<code>f</code>).
<p>
By default, the face indices are numbered with respect to the hull
vertices (as opposed to the input points), with a lowest index of 1, and
are arranged counter-clockwise. However, this can be changed by setting
{@link #POINT_RELATIVE POINT_RELATIVE}, {@link #INDEXED_FROM_ONE
INDEXED_FROM_ZERO}, or {@link #CLOCKWISE CLOCKWISE} in the indexFlags
parameter.
@param ps
stream used for printing
@param indexFlags
specifies index characteristics (0 results in the default).
@see QuickHull3D#getVertices()
@see QuickHull3D#getFaces() |
public boolean check(PrintStream ps, double tol)
{
// check to make sure all edges are fully connected
// and that the edges are convex
double dist;
double pointTol = 10 * tol;
if (!checkFaces(tolerance, ps)) {
return false;
}
// check point inclusion
for (int i = 0; i < numPoints; i++) {
Point3d pnt = pointBuffer[i].pnt;
for (Iterator it = faces.iterator(); it.hasNext();) {
Face face = (Face) it.next();
if (face.mark == Face.VISIBLE) {
dist = face.distanceToPlane(pnt);
if (dist > pointTol) {
if (ps != null) {
ps.println("Point " + i + " " + dist + " above face " + face.getVertexString());
}
return false;
}
}
}
}
return true;
} | Checks the correctness of the hull. This is done by making sure that no
faces are non-convex and that no points are outside any face. These tests
are performed using the distance tolerance <i>tol</i>. Faces are
considered non-convex if any edge is non-convex, and an edge is
non-convex if the centroid of either adjoining face is more than
<i>tol</i> above the plane of the other face. Similarly, a point is
considered outside a face if its distance to that face's plane is more
than 10 times <i>tol</i>.
<p>
If the hull has been {@link #triangulate triangulated}, then this routine
may fail if some of the resulting triangles are very small or thin.
@param ps
print stream for diagnostic messages; may be set to
<code>null</code> if no messages are desired.
@param tol
distance tolerance
@return true if the hull is valid
@see QuickHull3D#check(PrintStream) |
public static EmbeddedPostgresTestDatabaseRule embeddedDatabaseRule(@Nonnull final URL baseUrl, final String... personalities)
{
try {
return embeddedDatabaseRule(baseUrl.toURI(), personalities);
} catch (URISyntaxException e) {
throw new IllegalArgumentException(e);
}
} | Returns a {@link TestRule} to create a Postgres cluster, shared amongst all test cases in this JVM.
The rule contributes {@link Config} switches to configure each test case to get its own database. |
public static EmbeddedPostgresTestDatabaseRule embeddedDatabaseRule(@Nonnull final URI baseUri, final String... personalities)
{
return new EmbeddedPostgresTestDatabaseRule(baseUri, personalities);
} | Returns a {@link TestRule} to create a Postgres cluster, shared amongst all test cases in this JVM.
The rule contributes {@link Config} switches to configure each test case to get its own database. |
@Override
public final void onEvent(final StoreEvent<T> event, final long sequence, final boolean endOfBatch)
throws Exception {
try {
handle(event, sequence, endOfBatch);
} finally {
event.reset();
}
} | /*
(non-Javadoc)
@see com.lmax.disruptor.EventHandler#onEvent(java.lang.Object, long, boolean) |
public long addAll(final String... members) {
return doWithJedis(new JedisCallable<Long>() {
@Override
public Long call(Jedis jedis) {
return jedis.sadd(getKey(), members);
}
});
} | Adds to this set all of the elements in the specified members array
@param members the members to add
@return the number of members actually added |
public long removeAll(final String... members) {
return doWithJedis(new JedisCallable<Long>() {
@Override
public Long call(Jedis jedis) {
return jedis.srem(getKey(), members);
}
});
} | Removes from this set all of its elements that are contained in the specified members array
@param members the members to remove
@return the number of members actually removed |
public String pop() {
return doWithJedis(new JedisCallable<String>() {
@Override
public String call(Jedis jedis) {
return jedis.spop(getKey());
}
});
} | Removes and returns a random element from the set.
@return the removed element, or <code>null</code> when the key does not exist. |
public static List<?> xls2List(String xmlPath, File xlsFile) throws Exception {
return XlsUtil.xls2List(xmlPath, xlsFile);
} | 导入xls到List
@param xmlPath xml完整路径
@param xlsFile xls文件路径
@return List对象
@throws Exception |
public static List<?> xls2List(ExcelConfig config, File xlsFile) throws Exception {
return XlsUtil.xls2List(config, xlsFile);
} | 导入xls到List
@param config 配置
@param xlsFile xls文件路径
@return List对象
@throws Exception |
public static List<?> xls2List(String xmlPath, InputStream inputStream) throws Exception {
return XlsUtil.xls2List(xmlPath, inputStream);
} | 导入xls到List
@param xmlPath xml完整路径
@param inputStream xls文件流
@return List对象
@throws Exception |
public static List<?> xls2List(ExcelConfig config, InputStream inputStream) throws Exception {
return XlsUtil.xls2List(config, inputStream);
} | 导入xls到List
@param config 配置
@param inputStream xls文件流
@return List对象
@throws Exception |
public static boolean list2Xls(List<?> list, String xmlPath, String filePath, String fileName) throws Exception {
return XlsUtil.list2Xls(list, xmlPath, filePath, fileName);
} | 导出list对象到excel
@param list 导出的list
@param xmlPath xml完整路径
@param filePath 保存xls路径
@param fileName 保存xls文件名
@return 处理结果,true成功,false失败
@throws Exception |
public static boolean list2Xls(ExcelConfig config, List<?> list, String filePath, String fileName) throws Exception {
return XlsUtil.list2Xls(config, list, filePath, fileName);
} | 导出list对象到excel
@param config 配置
@param list 导出的list
@param filePath 保存xls路径
@param fileName 保存xls文件名
@return 处理结果,true成功,false失败
@throws Exception |
public static boolean list2Xls(List<?> list, String xmlPath, OutputStream outputStream) throws Exception {
return XlsUtil.list2Xls(list, xmlPath, outputStream);
} | 导出list对象到excel
@param list 导出的list
@param xmlPath xml完整路径
@param outputStream 输出流
@return 处理结果,true成功,false失败
@throws Exception |
public static boolean list2Xls(ExcelConfig config, List<?> list, OutputStream outputStream) throws Exception {
return XlsUtil.list2Xls(config, list, outputStream);
} | 导出list对象到excel
@param config 配置
@param list 导出的list
@param outputStream 输出流
@return 处理结果,true成功,false失败
@throws Exception |
public void add(Face vtx) {
if (head == null) {
head = vtx;
} else {
tail.next = vtx;
}
vtx.next = null;
tail = vtx;
} | Adds a vertex to the end of this list. |
public static <T> T fromXml(File xmlPath, Class<T> type) {
BufferedReader reader = null;
StringBuilder sb = null;
try {
reader = new BufferedReader(new InputStreamReader(new FileInputStream(xmlPath), ENCODING));
String line = null;
sb = new StringBuilder();
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
} catch (FileNotFoundException e) {
throw new IllegalArgumentException(e.getMessage());
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
//ignore
}
}
}
return fromXml(sb.toString(), type);
} | 从xml文件构建
@param xmlPath
@param type
@param <T>
@return |
public static <T> T fromXml(String xml, Class<T> type) {
if (xml == null || xml.trim().equals("")) {
return null;
}
JAXBContext jc = null;
Unmarshaller u = null;
T object = null;
try {
jc = JAXBContext.newInstance(type);
u = jc.createUnmarshaller();
object = (T) u.unmarshal(new ByteArrayInputStream(xml.getBytes(ENCODING)));
} catch (JAXBException e) {
throw new RuntimeException(e);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return object;
} | 从xml构建
@param xml
@param type
@param <T>
@return |
public static boolean toXml(Object object, File xml) {
if (object == null) {
throw new NullPointerException("object对象不存在!");
}
JAXBContext jc = null;
Marshaller m = null;
try {
jc = JAXBContext.newInstance(object.getClass());
m = jc.createMarshaller();
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
m.setProperty(Marshaller.JAXB_ENCODING, ENCODING);
m.marshal(object, xml);
return true;
} catch (Exception e) {
throw new RuntimeException(e);
}
} | 对象转xml并保存到文件
@param object
@return |
public static String toXml(Object object) {
if (object == null) {
throw new NullPointerException("object对象不存在!");
}
JAXBContext jc = null;
Marshaller m = null;
String xml = null;
try {
jc = JAXBContext.newInstance(object.getClass());
m = jc.createMarshaller();
ByteArrayOutputStream bos = new ByteArrayOutputStream();
m.marshal(object, bos);
xml = new String(bos.toByteArray());
} catch (Exception e) {
throw new RuntimeException(e);
}
return xml;
} | 对象转xml
@param object
@return |
public static void run() {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
GenXml frame = new GenXml();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
} | 运行xml生成器 |
private void ReadInTable(String clasz) {
this.clasz = clasz;
DefaultTableModel tableModel = (DefaultTableModel) table.getModel();
while (tableModel.getRowCount() > 0) {
tableModel.removeRow(0);
}
try {
BeanInfo sourceBean = Introspector.getBeanInfo(Class.forName(clasz), Object.class);
PropertyDescriptor[] ps = sourceBean.getPropertyDescriptors();
for (int i = 0; i < ps.length; i++) {
if (ps[i].getPropertyType().equals(Class.class)) {
continue;
}
tableModel.addRow(new Object[]{ps[i].getName(),
ps[i].getPropertyType().getName(), ps[i].getName()});
}
hasRead = true;
} catch (Exception e) {
JOptionPane.showMessageDialog(GenXml.this, "发生错误:" + e.getMessage());
}
} | 读入文件夹列表 |
@Override
public List<T> getAll(final Collection<String> ids) {
if (ids == null || ids.size() == 0) {
return Collections.<T> emptyList();
}
// we need a List of ids to partition
final List<String> idList;
if (ids instanceof List) {
idList = (List<String>) ids;
} else {
idList = Lists.newArrayList(ids);
}
// fetch records in groups of X
List<T> result = null;
for (final List<String> partition : Lists.partition(idList, config.getPartitionSize())) {
result = doGetAll(result, partition);
}
// make sure we always return non-null list
if (result == null) {
return Collections.<T> emptyList();
}
return result;
} | /*
(non-Javadoc)
@see com.arakelian.dao.Dao#getAll(java.util.Collection) |
@Override
public List<T> getAll(final String... ids) {
if (ids == null || ids.length == 0) {
return Collections.<T> emptyList();
}
// delegate to internal method that partitions the list into smaller groups and aggregates
// the result
return getAll(Lists.newArrayList(ids));
} | /*
(non-Javadoc)
@see com.arakelian.dao.Dao#getAll(java.lang.String[]) |
protected Object[] idsOf(final List<?> idsOrValues) {
// convert list to array that we can mutate
final Object[] ids = idsOrValues.toArray();
// mutate array to contain only non-empty ids
int length = 0;
for (int i = 0; i < ids.length;) {
final Object p = ids[i++];
if (p instanceof HasId) {
// only use values with ids that are non-empty
final String id = ((HasId) p).getId();
if (!StringUtils.isEmpty(id)) {
ids[length++] = id;
}
} else if (p instanceof String) {
// only use ids that are non-empty
final String id = p.toString();
if (!StringUtils.isEmpty(id)) {
ids[length++] = id;
}
} else if (p != null) {
throw new StoreException("Invalid id or value of type " + p);
}
}
// no ids in array
if (length == 0) {
return null;
}
// some ids in array
if (length != ids.length) {
final Object[] tmp = new Object[length];
System.arraycopy(ids, 0, tmp, 0, length);
return tmp;
}
// array was full
return ids;
} | Returns an array of non-empty ids from the given list of ids or values.
@param idsOrValues
list of ids and/or values
@return array of non-empty ids |
public long length() {
return doWithJedis(new JedisCallable<Long>() {
@Override
public Long call(Jedis jedis) {
return jedis.llen(getKey());
}
});
} | Get the length of the list (i.e. the number of elements).<br>
This is similar to {@link #size()} but is preferred since redis' capacity supports long typed values
@return the number of elements in the list |
public List<String> toList() {
return doWithJedis(new JedisCallable<List<String>>() {
@Override
public List<String> call(Jedis jedis) {
return jedis.lrange(getKey(), 0, jedis.llen(getKey())-1);
}
});
} | Get all the abstracted list value elements as {@link List}
@return a new {@link List} instance |
public long indexOf(final String element) {
return doWithJedis(new JedisCallable<Long>() {
@Override
public Long call(Jedis jedis) {
return doIndexOf(jedis, element);
}
});
} | Find the index of the first matching element in the list
@param element the element value to find
@return the index of the first matching element, or <code>-1</code> if none found |
public String get(final long index) {
return doWithJedis(new JedisCallable<String>() {
@Override
public String call(Jedis jedis) {
return jedis.lindex(getKey(), index);
}
});
} | Get the element value in the list by index
@param index the position in the list from which to get the element
@return the element value |
public List<String> subList(final long fromIndex, final long toIndex) {
return doWithJedis(new JedisCallable<List<String>>() {
@Override
public List<String> call(Jedis jedis) {
return jedis.lrange(getKey(), fromIndex, toIndex);
}
});
} | Get a sub-list of this list
@param fromIndex index of the first element in the sub-list (inclusive)
@param toIndex index of the last element in the sub-list (inclusive)
@return the sub-list |
@Override
public boolean checkMgtKeyInUse(String CorpNum, MgtKeyType KeyType,
String MgtKey) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
try {
TaxinvoiceInfo info = httpget("/Taxinvoice/" + KeyType.name() + "/"
+ MgtKey, CorpNum, null, TaxinvoiceInfo.class);
return (info.getItemKey() == null || info.getItemKey().isEmpty()) == false;
} catch (PopbillException PE) {
if (PE.getCode() == -11000005)
return false;
throw PE;
}
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#checkMgtKeyInUse(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public EmailPublicKey[] getEmailPublicKeys(String CorpNum)
throws PopbillException {
return httpget("/Taxinvoice/EmailPublicKeys", CorpNum, null,
EmailPublicKey[].class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getEmailPublicKeys(java.lang.String) |
@Override
public Response register(String CorpNum, Taxinvoice taxinvoice)
throws PopbillException {
return register(CorpNum, taxinvoice, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#register(java.lang.String, com.popbill.api.taxinvoice.Taxinvoice) |
@Override
public Response register(String CorpNum, Taxinvoice taxinvoice,
String UserID) throws PopbillException {
return register(CorpNum, taxinvoice, UserID, false);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#register(java.lang.String, com.popbill.api.taxinvoice.Taxinvoice, java.lang.String) |
@Override
public Response register(String CorpNum, Taxinvoice taxinvoice,
String UserID, boolean writeSpecification) throws PopbillException {
if (taxinvoice == null)
throw new PopbillException(-99999999, "세금계산서 정보가 입력되지 않았습니다.");
String PostData = toJsonString(taxinvoice);
if (writeSpecification) {
PostData = "{\"writeSpecification\":true," + PostData.substring(1);
}
return httppost("/Taxinvoice", CorpNum, PostData, UserID,
Response.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#register(java.lang.String, com.popbill.api.taxinvoice.Taxinvoice, java.lang.String, boolean) |
@Override
public Response update(String CorpNum, MgtKeyType KeyType, String MgtKey,
Taxinvoice taxinvoice) throws PopbillException {
return update(CorpNum, KeyType, MgtKey, taxinvoice, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#update(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, com.popbill.api.taxinvoice.Taxinvoice) |
@Override
public Response update(String CorpNum, MgtKeyType KeyType, String MgtKey,
Taxinvoice taxinvoice, String UserID) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
if (taxinvoice == null)
throw new PopbillException(-99999999, "세금계산서 정보가 입력되지 않았습니다.");
String PostData = toJsonString(taxinvoice);
return httppost("/Taxinvoice/" + KeyType.name() + "/" + MgtKey,
CorpNum, PostData, UserID, "PATCH", Response.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#update(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, com.popbill.api.taxinvoice.Taxinvoice, java.lang.String) |
@Override
public Response delete(String CorpNum, MgtKeyType KeyType, String MgtKey,
String UserID) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
return httppost("/Taxinvoice/" + KeyType.name() + "/" + MgtKey,
CorpNum, null, UserID, "DELETE", Response.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#delete(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String) |
@Override
public Response send(String CorpNum, MgtKeyType KeyType, String MgtKey,
String Memo) throws PopbillException {
return send(CorpNum, KeyType, MgtKey, Memo, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#send(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String) |
@Override
public Response send(String CorpNum, MgtKeyType KeyType, String MgtKey,
String Memo, String EmailSubject, String UserID) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
SendRequest request = new SendRequest();
request.memo = Memo;
request.emailSubject = EmailSubject;
String PostData = toJsonString(request);
return httppost("/Taxinvoice/" + KeyType.name() + "/" + MgtKey,
CorpNum, PostData, UserID, "SEND", Response.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#send(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String, java.lang.String) |
@Override
public IssueResponse issue(String CorpNum, MgtKeyType KeyType, String MgtKey,
String Memo) throws PopbillException {
return issue(CorpNum, KeyType, MgtKey, Memo, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#issue(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String) |
@Override
public IssueResponse issue(String CorpNum, MgtKeyType KeyType, String MgtKey,
String Memo, String EmailSubject, boolean ForceIssue, String UserID)
throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
IssueRequest request = new IssueRequest();
request.memo = Memo;
request.emailSubject = EmailSubject;
request.forceIssue = ForceIssue;
String PostData = toJsonString(request);
return httppost("/Taxinvoice/" + KeyType.name() + "/" + MgtKey,
CorpNum, PostData, UserID, "ISSUE", IssueResponse.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#issue(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String, java.lang.String, boolean, java.lang.String) |
@Override
public Response sendToNTS(String CorpNum, MgtKeyType KeyType, String MgtKey)
throws PopbillException {
return sendToNTS(CorpNum, KeyType, MgtKey, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#sendToNTS(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public Response sendEmail(String CorpNum, MgtKeyType KeyType,
String MgtKey, String Receiver) throws PopbillException {
return sendEmail(CorpNum, KeyType, MgtKey, Receiver, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#sendEmail(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String) |
@Override
public Response sendSMS(String CorpNum, MgtKeyType KeyType, String MgtKey,
String Sender, String Receiver, String Contents)
throws PopbillException {
return sendSMS(CorpNum, KeyType, MgtKey, Sender, Receiver, Contents,
null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#sendSMS(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String, java.lang.String, java.lang.String) |
@Override
public Response sendFAX(String CorpNum, MgtKeyType KeyType, String MgtKey,
String Sender, String Receiver) throws PopbillException {
return sendFAX(CorpNum, KeyType, MgtKey, Sender, Receiver, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#sendFAX(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String, java.lang.String) |
@Override
public Taxinvoice getDetailInfo(String CorpNum, MgtKeyType KeyType,
String MgtKey) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
return httpget("/Taxinvoice/" + KeyType.name() + "/" + MgtKey
+ "?Detail", CorpNum, null, Taxinvoice.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getDetailInfo(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public TaxinvoiceInfo getInfo(String CorpNum, MgtKeyType KeyType,
String MgtKey) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
return httpget("/Taxinvoice/" + KeyType.name() + "/" + MgtKey, CorpNum,
null, TaxinvoiceInfo.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getInfo(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public TaxinvoiceInfo[] getInfos(String CorpNum, MgtKeyType KeyType,
String[] MgtKeyList) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKeyList == null || MgtKeyList.length == 0)
throw new PopbillException(-99999999, "관리번호 목록이 입력되지 않았습니다.");
String PostData = toJsonString(MgtKeyList);
return httppost("/Taxinvoice/" + KeyType.name(), CorpNum, PostData,
null, TaxinvoiceInfo[].class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getInfos(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String[]) |
@Override
public TaxinvoiceLog[] getLogs(String CorpNum, MgtKeyType KeyType,
String MgtKey) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
return httpget(
"/Taxinvoice/" + KeyType.name() + "/" + MgtKey + "/Logs",
CorpNum, null, TaxinvoiceLog[].class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getLogs(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public String getPopUpURL(String CorpNum, MgtKeyType KeyType,
String MgtKey, String UserID) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
URLResponse response = httpget("/Taxinvoice/" + KeyType.name() + "/"
+ MgtKey + "?TG=POPUP", CorpNum, UserID, URLResponse.class);
return response.url;
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getPopUpURL(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String) |
@Override
public String getMailURL(String CorpNum, MgtKeyType KeyType, String MgtKey) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
return getMailURL(CorpNum, KeyType, MgtKey, null);
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getMailURL(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public String getViewURL(String CorpNum, MgtKeyType KeyType, String MgtKey) throws PopbillException {
return getViewURL(CorpNum, KeyType, MgtKey, null);
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getViewURL(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public String getMassPrintURL(String CorpNum, MgtKeyType KeyType,
String[] MgtKeyList) throws PopbillException {
return getMassPrintURL(CorpNum, KeyType, MgtKeyList, null);
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getMassPrintURL(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String[]) |
@Override
public String getMassPrintURL(String CorpNum, MgtKeyType KeyType,
String[] MgtKeyList, String UserID) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKeyList == null || MgtKeyList.length == 0)
throw new PopbillException(-99999999, "관리번호 목록이 입력되지 않았습니다.");
String PostData = toJsonString(MgtKeyList);
URLResponse response = httppost("/Taxinvoice/" + KeyType.name()
+ "?Print", CorpNum, PostData, UserID, URLResponse.class);
return response.url;
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getMassPrintURL(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String[], java.lang.String) |
@Override
public Response attachFile(String CorpNum, MgtKeyType KeyType,
String MgtKey, String DisplayName, InputStream FileData)
throws PopbillException {
return attachFile(CorpNum, KeyType, MgtKey, DisplayName, FileData, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#attachFile(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String, java.io.InputStream) |
@Override
public AttachedFile[] getFiles(String CorpNum, MgtKeyType KeyType,
String MgtKey) throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (MgtKey == null || MgtKey.isEmpty())
throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다.");
return httpget("/Taxinvoice/" + KeyType.name() + "/" + MgtKey
+ "/Files", CorpNum, null, AttachedFile[].class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#getFiles(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String) |
@Override
public Response deleteFile(String CorpNum, MgtKeyType KeyType,
String MgtKey, String FileID) throws PopbillException {
return deleteFile(CorpNum, KeyType, MgtKey, FileID, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#deleteFile(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String) |
@Override
public TISearchResult Search(String CorpNum, MgtKeyType KeyType, String DType,
String SDate, String EDate, String[] State, String[] Type, String[] TaxType,
Boolean LateOnly, Integer Page, Integer PerPage, String Order) throws PopbillException {
return Search(CorpNum, KeyType, DType, SDate, EDate, State, Type, TaxType, null, LateOnly,
null, null, null, null, Page, PerPage, Order, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#Search(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String,
java.lang.String, java.lang.String, java.lang.String[], java.lang.String[],
boolean, integer, integer) |
@Override
public TISearchResult Search(String CorpNum, MgtKeyType KeyType,
String DType, String SDate, String EDate, String[] State,
String[] Type, String[] TaxType, String[] IssueType, Boolean LateOnly,
String TaxRegIDType, String TaxRegID, String TaxRegIDYN,
String QString, Integer Page, Integer PerPage, String Order, String InterOPYN)
throws PopbillException {
if (KeyType == null)
throw new PopbillException(-99999999, "관리번호형태가 입력되지 않았습니다.");
if (DType == null || DType.isEmpty())
throw new PopbillException(-99999999, "검색일자 유형이 입력되지 않았습니다.");
if (SDate == null || SDate.isEmpty())
throw new PopbillException(-99999999, "시작일자가 입력되지 않았습니다.");
if (EDate == null || EDate.isEmpty())
throw new PopbillException(-99999999, "종료일자가 입력되지 않았습니다.");
String uri = "/Taxinvoice/" + KeyType;
uri += "?DType=" + DType;
uri += "&SDate=" + SDate;
uri += "&EDate=" + EDate;
uri += "&State=" + Arrays.toString(State)
.replaceAll("\\[|\\]|\\s", "");
uri += "&Type=" + Arrays.toString(Type)
.replaceAll("\\[|\\]|\\s", "");
uri += "&TaxType=" + Arrays.toString(TaxType)
.replaceAll("\\[|\\]|\\s", "");
if (IssueType != null) {
uri += "&IssueType=" + Arrays.toString(IssueType)
.replaceAll("\\[|\\]|\\s", "");
}
if (LateOnly != null) {
if (LateOnly) {
uri += "&LateOnly=1";
} else {
uri += "&LateOnly=0";
}
}
if (TaxRegIDType != null && TaxRegIDType != "") {
uri += "&TaxRegIDType=" + TaxRegIDType;
}
if (TaxRegID != null && TaxRegID != "") {
uri += "&TaxRegID=" + TaxRegID;
}
if (TaxRegIDYN != null && TaxRegIDYN != "") {
uri += "&TaxRegIDYN=" + TaxRegIDYN;
}
if (InterOPYN != null && InterOPYN != "") {
uri += "&InterOPYN=" + InterOPYN;
}
if (QString != null && QString != "") {
uri += "&QString=" + QString;
}
uri += "&Page=" + Integer.toString(Page);
uri += "&PerPage=" + Integer.toString(PerPage);
uri += "&Order=" + Order;
return httpget(uri, CorpNum, null, TISearchResult.class);
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#Search(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String, java.lang.String, java.lang.String[], java.lang.String[], java.lang.String[], java.lang.String[], java.lang.Boolean, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.String, java.lang.String) |
@Override
public IssueResponse registIssue(String CorpNum, Taxinvoice taxinvoice,
Boolean WriteSpecification) throws PopbillException {
return registIssue(CorpNum, taxinvoice, WriteSpecification, null, false, null, null, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#registIssue(java.lang.String, com.popbill.api.Taxinvoice, Boolean) |
@Override
public IssueResponse registIssue(String CorpNum, Taxinvoice taxinvoice,
String Memo, Boolean ForceIssue) throws PopbillException {
return registIssue(CorpNum, taxinvoice, false, Memo, ForceIssue, null, null, null);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#registIssue(java.lang.String, com.popbill.api.Taxinvoice, String, Boolean) |
@Override
public IssueResponse registIssue(String CorpNum, Taxinvoice taxinvoice,
Boolean WriteSpecification, String Memo, Boolean ForceIssue,
String DealInvoiceKey, String EmailSubject, String UserID)
throws PopbillException {
if (taxinvoice == null)
throw new PopbillException(-99999999, "세금계산서 정보가 입력되지 않았습니다.");
if (WriteSpecification)
taxinvoice.setWriteSpecification(true);
if (Memo != null)
taxinvoice.setMemo(Memo);
if (ForceIssue)
taxinvoice.setForceIssue(true);
if (DealInvoiceKey != null)
taxinvoice.setDealInvoiceMgtKey(DealInvoiceKey);
if (EmailSubject != null)
taxinvoice.setEmailSubject(EmailSubject);
String PostData = toJsonString(taxinvoice);
return httppost("/Taxinvoice", CorpNum, PostData,
UserID, "ISSUE", IssueResponse.class);
} | /* (non-Javadoc)
@see com.popbill.api.TaxinvoiceService#registIssue(java.lang.String, com.popbill.api.Taxinvoice, Boolean, java.lang.string,
Boolean, java.lang.String, java.lang.String, java.lang.String) |
@Override
public Response attachStatement(String CorpNum, MgtKeyType KeyType, String MgtKey,
int SubItemCode, String SubMgtKey) throws PopbillException {
DocRequest request = new DocRequest();
request.ItemCode = Integer.toString(SubItemCode);
request.MgtKey = SubMgtKey;
String PostData = toJsonString(request);
return httppost("/Taxinvoice/" + KeyType.name() + "/" + MgtKey + "/AttachStmt",
CorpNum, PostData, null, "", Response.class);
} | /*
/*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#attachStatement(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, int, java.lang.String) |
@Override
public EmailSendConfig[] listEmailConfig(String CorpNum) throws PopbillException {
return httpget("/Taxinvoice/EmailSendConfig", CorpNum, null, EmailSendConfig[].class);
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#listEmailConfig(java.lang.String) |
@Override
public EmailSendConfig[] listEmailConfig(String CorpNum, String UserID) throws PopbillException {
return httpget("/Taxinvoice/EmailSendConfig", CorpNum, UserID, EmailSendConfig[].class);
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#listEmailConfig(java.lang.String, java.lang.String) |
public Response assignMgtKey(String corpNum, MgtKeyType keyType, String itemKey,
String mgtKey) throws PopbillException {
return assignMgtKey(corpNum, keyType, itemKey, mgtKey, null);
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#assignMgtKey(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String) |
public Response assignMgtKey(String corpNum, MgtKeyType keyType, String itemKey,
String mgtKey, String userID) throws PopbillException {
if (itemKey == null || itemKey.isEmpty())
throw new PopbillException(-99999999, "아이템키(ItemKey)가 입력되지 않았습니다.");
if (mgtKey == null || mgtKey.isEmpty())
throw new PopbillException(-99999999, "문서관리번호(MgtKey)가 입력되지 않았습니다.");
String PostData = "MgtKey=" + mgtKey;
return httppost("/Taxinvoice/" + itemKey + "/" + keyType.name(),
corpNum, PostData, userID, "", Response.class, "application/x-www-form-urlencoded; charset=utf-8");
} | /*
(non-Javadoc)
@see com.popbill.api.TaxinvoiceService#assignMgtKey(java.lang.String, com.popbill.api.taxinvoice.MgtKeyType, java.lang.String, java.lang.String, java.lang.String) |
private void ensureNext() {
// Check if the current scan result has more keys (i.e. the index did not reach the end of the result list)
if (resultIndex < scanResult.getResult().size()) {
return;
}
// Since the current scan result was fully iterated,
// if there is another cursor scan it and ensure next key (recursively)
if (!FIRST_CURSOR.equals(scanResult.getStringCursor())) {
scanResult = scan(scanResult.getStringCursor(), scanParams);
resultIndex = 0;
ensureNext();
}
} | Make sure the result index points to the next available key in the scan result, if exists. |
public void add(Vertex vtx) {
if (head == null) {
head = vtx;
} else {
tail.next = vtx;
}
vtx.prev = tail;
vtx.next = null;
tail = vtx;
} | Adds a vertex to the end of this list. |
public void addAll(Vertex vtx) {
if (head == null) {
head = vtx;
} else {
tail.next = vtx;
}
vtx.prev = tail;
while (vtx.next != null) {
vtx = vtx.next;
}
tail = vtx;
} | Adds a chain of vertices to the end of this list. |
public void delete(Vertex vtx) {
if (vtx.prev == null) {
head = vtx.next;
} else {
vtx.prev.next = vtx.next;
}
if (vtx.next == null) {
tail = vtx.prev;
} else {
vtx.next.prev = vtx.prev;
}
} | Deletes a vertex from this list. |
public void delete(Vertex vtx1, Vertex vtx2) {
if (vtx1.prev == null) {
head = vtx2.next;
} else {
vtx1.prev.next = vtx2.next;
}
if (vtx2.next == null) {
tail = vtx1.prev;
} else {
vtx2.next.prev = vtx1.prev;
}
} | Deletes a chain of vertices from this list. |
public void insertBefore(Vertex vtx, Vertex next) {
vtx.prev = next.prev;
if (next.prev == null) {
head = vtx;
} else {
next.prev.next = vtx;
}
vtx.next = next;
next.prev = vtx;
} | Inserts a vertex into this list before another specificed vertex. |
private static void freeTempLOB(ClobWrapper clob, BlobWrapper blob)
{
try
{
if (clob != null)
{
// If the CLOB is open, close it
if (clob.isOpen())
{
clob.close();
}
// Free the memory used by this CLOB
clob.freeTemporary();
}
if (blob != null)
{
// If the BLOB is open, close it
if (blob.isOpen())
{
blob.close();
}
// Free the memory used by this BLOB
blob.freeTemporary();
}
}
catch (Exception e)
{
logger.error("Error during temporary LOB release", e);
}
} | Frees the temporary LOBs when an exception is raised in the application
or when the LOBs are no longer needed. If the LOBs are not freed, the
space used by these LOBs are not reclaimed.
@param clob CLOB-wrapper to free or null
@param blob BLOB-wrapper to free or null |
public void check(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException
{
ensureElementClassRef(collDef, checkLevel);
checkInheritedForeignkey(collDef, checkLevel);
ensureCollectionClass(collDef, checkLevel);
checkProxyPrefetchingLimit(collDef, checkLevel);
checkOrderby(collDef, checkLevel);
checkQueryCustomizer(collDef, checkLevel);
} | Checks the given collection descriptor.
@param collDef The collection descriptor
@param checkLevel The amount of checks to perform
@exception ConstraintException If a constraint has been violated |
private void ensureElementClassRef(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String arrayElementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF);
if (!collDef.hasProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF))
{
if (arrayElementClassName != null)
{
// we use the array element type
collDef.setProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF, arrayElementClassName);
}
else
{
throw new ConstraintException("Collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" does not specify its element class");
}
}
// now checking the element type
ModelDef model = (ModelDef)collDef.getOwner().getOwner();
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF);
ClassDescriptorDef elementClassDef = model.getClass(elementClassName);
if (elementClassDef == null)
{
throw new ConstraintException("Collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" references an unknown class "+elementClassName);
}
if (!elementClassDef.getBooleanProperty(PropertyHelper.OJB_PROPERTY_OJB_PERSISTENT, false))
{
throw new ConstraintException("The element class "+elementClassName+" of the collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" is not persistent");
}
if (CHECKLEVEL_STRICT.equals(checkLevel) && (arrayElementClassName != null))
{
// specified element class must be a subtype of the element type
try
{
InheritanceHelper helper = new InheritanceHelper();
if (!helper.isSameOrSubTypeOf(elementClassDef, arrayElementClassName, true))
{
throw new ConstraintException("The element class "+elementClassName+" of the collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" is not the same or a subtype of the array base type "+arrayElementClassName);
}
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the collection "+collDef.getName()+" in class "+collDef.getOwner().getName());
}
}
// we're adjusting the property to use the classloader-compatible form
collDef.setProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF, elementClassDef.getName());
} | Ensures that the given collection descriptor has a valid element-class-ref property.
@param collDef The collection descriptor
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If element-class-ref could not be determined or is invalid |
private void checkInheritedForeignkey(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
if (!collDef.isInherited() && !collDef.isNested())
{
return;
}
if (!collDef.hasProperty(PropertyHelper.OJB_PROPERTY_INDIRECTION_TABLE))
{
return;
}
String localFk = collDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
String inheritedFk = collDef.getOriginal().getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);
if (!CommaListIterator.sameLists(localFk, inheritedFk))
{
throw new ConstraintException("The foreignkey property has been changed for the m:n collection "+collDef.getName()+" in class "+collDef.getOwner().getName());
}
} | Checks that the foreignkey is not modified in an inherited/nested m:n collection descriptor.
@param collDef The collection descriptor
@param checkLevel The current check level (this constraint is checked in basic and strict) |
private void ensureCollectionClass(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_ARRAY_ELEMENT_CLASS_REF))
{
// an array cannot have a collection-class specified
if (collDef.hasProperty(PropertyHelper.OJB_PROPERTY_COLLECTION_CLASS))
{
throw new ConstraintException("Collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" is an array but does specify collection-class");
}
else
{
// no further processing necessary as its an array
return;
}
}
if (CHECKLEVEL_STRICT.equals(checkLevel))
{
InheritanceHelper helper = new InheritanceHelper();
ModelDef model = (ModelDef)collDef.getOwner().getOwner();
String specifiedClass = collDef.getProperty(PropertyHelper.OJB_PROPERTY_COLLECTION_CLASS);
String variableType = collDef.getProperty(PropertyHelper.OJB_PROPERTY_VARIABLE_TYPE);
try
{
if (specifiedClass != null)
{
// if we have a specified class then it has to implement the manageable collection and be a sub type of the variable type
if (!helper.isSameOrSubTypeOf(specifiedClass, variableType))
{
throw new ConstraintException("The type "+specifiedClass+" specified as collection-class of the collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" is not a sub type of the variable type "+variableType);
}
if (!helper.isSameOrSubTypeOf(specifiedClass, MANAGEABLE_COLLECTION_INTERFACE))
{
throw new ConstraintException("The type "+specifiedClass+" specified as collection-class of the collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" does not implement "+MANAGEABLE_COLLECTION_INTERFACE);
}
}
else
{
// no collection class specified so the variable type has to be a collection type
if (helper.isSameOrSubTypeOf(variableType, MANAGEABLE_COLLECTION_INTERFACE))
{
// we can specify it as a collection-class as it is an manageable collection
collDef.setProperty(PropertyHelper.OJB_PROPERTY_COLLECTION_CLASS, variableType);
}
else if (!helper.isSameOrSubTypeOf(variableType, JAVA_COLLECTION_INTERFACE))
{
throw new ConstraintException("The collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" needs the collection-class attribute as its variable type does not implement "+JAVA_COLLECTION_INTERFACE);
}
}
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("Could not find the class "+ex.getMessage()+" on the classpath while checking the collection "+collDef.getName()+" in class "+collDef.getOwner().getName());
}
}
} | Ensures that the given collection descriptor has the collection-class property if necessary.
@param collDef The collection descriptor
@param checkLevel The current check level (this constraint is checked in basic (partly) and strict)
@exception ConstraintException If collection-class is given for an array or if no collection-class is given but required |
private void checkOrderby(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException
{
if (CHECKLEVEL_NONE.equals(checkLevel))
{
return;
}
String orderbySpec = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ORDERBY);
if ((orderbySpec == null) || (orderbySpec.length() == 0))
{
return;
}
ClassDescriptorDef ownerClass = (ClassDescriptorDef)collDef.getOwner();
String elementClassName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_ELEMENT_CLASS_REF).replace('$', '.');
ClassDescriptorDef elementClass = ((ModelDef)ownerClass.getOwner()).getClass(elementClassName);
FieldDescriptorDef fieldDef;
String token;
String fieldName;
String ordering;
int pos;
for (CommaListIterator it = new CommaListIterator(orderbySpec); it.hasNext();)
{
token = it.getNext();
pos = token.indexOf('=');
if (pos == -1)
{
fieldName = token;
ordering = null;
}
else
{
fieldName = token.substring(0, pos);
ordering = token.substring(pos + 1);
}
fieldDef = elementClass.getField(fieldName);
if (fieldDef == null)
{
throw new ConstraintException("The field "+fieldName+" specified in the orderby attribute of the collection "+collDef.getName()+" in class "+ownerClass.getName()+" hasn't been found in the element class "+elementClass.getName());
}
if ((ordering != null) && (ordering.length() > 0) &&
!"ASC".equals(ordering) && !"DESC".equals(ordering))
{
throw new ConstraintException("The ordering "+ordering+" specified in the orderby attribute of the collection "+collDef.getName()+" in class "+ownerClass.getName()+" is invalid");
}
}
} | Checks the orderby attribute.
@param collDef The collection descriptor
@param checkLevel The current check level (this constraint is checked in basic and strict)
@exception ConstraintException If the value for orderby is invalid (unknown field or ordering) |
private void checkQueryCustomizer(CollectionDescriptorDef collDef, String checkLevel) throws ConstraintException
{
if (!CHECKLEVEL_STRICT.equals(checkLevel))
{
return;
}
String queryCustomizerName = collDef.getProperty(PropertyHelper.OJB_PROPERTY_QUERY_CUSTOMIZER);
if (queryCustomizerName == null)
{
return;
}
try
{
InheritanceHelper helper = new InheritanceHelper();
if (!helper.isSameOrSubTypeOf(queryCustomizerName, QUERY_CUSTOMIZER_INTERFACE))
{
throw new ConstraintException("The class "+queryCustomizerName+" specified as query-customizer of collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" does not implement the interface "+QUERY_CUSTOMIZER_INTERFACE);
}
}
catch (ClassNotFoundException ex)
{
throw new ConstraintException("The class "+ex.getMessage()+" specified as query-customizer of collection "+collDef.getName()+" in class "+collDef.getOwner().getName()+" was not found on the classpath");
}
} | Checks the query-customizer setting of the given collection descriptor.
@param collDef The collection descriptor
@param checkLevel The current check level (this constraint is only checked in strict)
@exception ConstraintException If the constraint has been violated |
public LockIsolation getStrategyFor(int isolationLevel)
{
switch(isolationLevel)
{
case LockManager.IL_READ_UNCOMMITTED:
return readUncommitedStrategy;
case LockManager.IL_READ_COMMITTED:
return readCommitedStrategy;
case LockManager.IL_REPEATABLE_READ:
return readRepeatableStrategy;
case LockManager.IL_SERIALIZABLE:
return serializableStrategy;
default:
return readUncommitedStrategy;
}
} | Obtains a lock isolation for Object obj. The Strategy to be used is
selected by evaluating the ClassDescriptor of obj.getClass(). |
public static ClassLoader getClassLoader()
{
final ClassLoader ojbClassLoader;
if (_classLoader != null)
{
ojbClassLoader = _classLoader;
}
else
{
final ClassLoader threadCtxtClassLoader;
threadCtxtClassLoader = Thread.currentThread().getContextClassLoader();
if (threadCtxtClassLoader == null)
{
// mkalen: happens only in "obscure" situations using JNI, revert to system CL
ojbClassLoader = ClassLoader.getSystemClassLoader();
}
else
{
ojbClassLoader = threadCtxtClassLoader;
}
}
return ojbClassLoader;
} | Returns the class loader currently used by OJB. Defaults to the class loader of
the current thread (<code>Thread.currentThread().getContextClassLoader()</code>)
if not set differently. If class loader is not explicitly set and the loader for
the current thread context is null, the JVM default class loader will be used.
@return The classloader used by OJB
@see #setClassLoader(ClassLoader) |
Subsets and Splits