code
stringlengths
67
466k
docstring
stringlengths
1
13.2k
@Override public Response register(String CorpNum, Cashbill cashbill) throws PopbillException { return register(CorpNum, cashbill, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#register(java.lang.String, com.popbill.api.cashbill.Cashbill)
@Override public Response register(String CorpNum, Cashbill cashbill, String UserID) throws PopbillException { if (cashbill == null) throw new PopbillException(-99999999, "현금영수증정보가 입력되지 않았습니다."); String PostData = toJsonString(cashbill); return httppost("/Cashbill",CorpNum, PostData, UserID, Response.class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#register(java.lang.String, com.popbill.api.cashbill.Cashbill, java.lang.String)
@Override public Response update(String CorpNum, String MgtKey, Cashbill cashbill) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); return update(CorpNum, MgtKey, cashbill, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#update(java.lang.String, java.lang.String, com.popbill.api.cashbill.Cashbill)
@Override public Response update(String CorpNum, String MgtKey, Cashbill cashbill, String UserID) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); String PostData = toJsonString(cashbill); return httppost("/Cashbill/"+MgtKey, CorpNum, PostData, UserID, "PATCH", Response.class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#update(java.lang.String, java.lang.String, com.popbill.api.cashbill.Cashbill, java.lang.String)
@Override public Response delete(String CorpNum, String MgtKey) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); return delete(CorpNum, MgtKey, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#delete(java.lang.String, java.lang.String)
@Override public Response issue(String CorpNum, String MgtKey, String Memo, String UserID) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); String PostData = toJsonString(new MemoRequest(Memo)); return httppost("/Cashbill/" + MgtKey, CorpNum, PostData, UserID, "ISSUE", Response.class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#issue(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
@Override public Response sendSMS(String CorpNum, String MgtKey, String Sender, String Receiver, String Contents) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); return sendSMS(CorpNum, MgtKey, Sender, Receiver, Contents, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#sendSMS(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)
@Override public Cashbill getDetailInfo(String CorpNum, String MgtKey) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); return httpget("/Cashbill/" + MgtKey + "?Detail", CorpNum, null, Cashbill.class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getDetailInfo(java.lang.String, java.lang.String)
@Override public CashbillInfo getInfo(String CorpNum, String MgtKey) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); return httpget("/Cashbill/" + MgtKey, CorpNum, null, CashbillInfo.class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getInfo(java.lang.String, java.lang.String)
@Override public CashbillInfo[] getInfos(String CorpNum, String[] MgtKeyList) throws PopbillException { if (MgtKeyList == null || MgtKeyList.length == 0) throw new PopbillException(-99999999, "관리번호배열이 입력되지 않았습니다."); String PostData = toJsonString(MgtKeyList); return httppost("/Cashbill/States", CorpNum, PostData, null, CashbillInfo[].class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getInfos(java.lang.String, java.lang.String[])
@Override public CashbillLog[] getLogs(String CorpNum, String MgtKey) throws PopbillException { if (MgtKey == null || MgtKey.isEmpty()) throw new PopbillException(-99999999, "관리번호가 입력되지 않았습니다."); return httpget("/Cashbill/" + MgtKey +"/Logs", CorpNum, null, CashbillLog[].class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getLogs(java.lang.String, java.lang.String)
@Override public String getPrintURL(String CorpNum, String MgtKey) throws PopbillException { return getPrintURL(CorpNum, MgtKey, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getPrintURL(java.lang.String, java.lang.String)
@Override public String getEPrintURL(String CorpNum, String MgtKey) throws PopbillException { return getEPrintURL(CorpNum, MgtKey, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getEPrintURL(java.lang.String, java.lang.String)
@Override public String getMailURL(String CorpNum, String MgtKey) throws PopbillException { return getMailURL(CorpNum, MgtKey, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getMailURL(java.lang.String, java.lang.String)
@Override public String getPopUpURL(String CorpNum, String MgtKey) throws PopbillException { return getPopUpURL(CorpNum, MgtKey, null); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getPopUpURL(java.lang.String, java.lang.String)
@Override public Response registIssue(String CorpNum, Cashbill cashbill, String memo, String UserID) throws PopbillException { if (cashbill == null) throw new PopbillException(-99999999, "현금영수증정보가 입력되지 않았습니다."); if (memo != null) cashbill.setMemo(memo); String PostData = toJsonString(cashbill); return httppost("/Cashbill", CorpNum, PostData, UserID, "ISSUE", Response.class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#registIssue(java.lang.String, com.popbill.api.cashbill.Cashbill, java.lang.String, java.lang.String)
public CBSearchResult search(String CorpNum, String DType, String SDate, String EDate, String[] State, String[] TradeType, String[] TradeUsage, String[] TaxationType, int Page, int PerPage, String Order) throws PopbillException { return search(CorpNum, DType, SDate, EDate, State, TradeType, TradeUsage, TaxationType, "", Page, PerPage, Order); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#search(java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String[], java.lang.String[], java.lang.String[], java.lang.String[], int, int, java.lang.String)
@Override public ChargeInfo getChargeInfo(String CorpNum) throws PopbillException { return httpget("/Cashbill/ChargeInfo", CorpNum, null, ChargeInfo.class); }
/* (non-Javadoc) @see com.popbill.api.CashbillService#getChargeInfo(java.lang.String)
@Override public HTTaxinvoiceJobState getJobState(String CorpNum, String JobID) throws PopbillException { return getJobState(CorpNum, JobID, null); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#getJobState(java.lang.String, java.lang.String)
@Override public HTTaxinvoiceJobState[] listActiveJob(String CorpNum, String UserID) throws PopbillException { return httpget("/HomeTax/Taxinvoice/JobList", CorpNum, UserID, HTTaxinvoiceJobState[].class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#ListActiveJob(java.lang.String, java.lang.String)
@Override public HTTaxinvoiceSearchResult search(String CorpNum, String JobID, String[] Type, String[] TaxType, String[] PurposeType, String TaxRegIDYN, String TaxRegIDType, String TaxRegID, Integer Page, Integer PerPage, String Order) throws PopbillException{ return search(CorpNum, JobID, Type, TaxType, PurposeType, TaxRegIDYN, TaxRegIDType, TaxRegID, Page, PerPage, Order, null); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#Search(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.Integer, java.lang.Integer, java.lang.String)
@Override public HTTaxinvoiceSearchResult search(String CorpNum, String JobID, String[] Type, String[] TaxType, String[] PurposeType, String TaxRegIDYN, String TaxRegIDType, String TaxRegID, Integer Page, Integer PerPage, String Order, String UserID) throws PopbillException { if (JobID.length() != 18) throw new PopbillException(-99999999, "작업아이디가 올바르지 않습니다."); String uri = "/HomeTax/Taxinvoice/"+JobID; uri += "?Type=" + Arrays.toString(Type) .replaceAll("\\[|\\]|\\s", ""); uri += "&TaxType=" + Arrays.toString(TaxType) .replaceAll("\\[|\\]|\\s", ""); uri += "&PurposeType=" + Arrays.toString(PurposeType) .replaceAll("\\[|\\]|\\s", ""); if (TaxRegIDType != "" && TaxRegIDType != null) uri += "&TaxRegIDType=" + TaxRegIDType; if (TaxRegIDYN != "" && TaxRegIDYN != null) uri += "&TaxRegIDYN=" + TaxRegIDYN; if (TaxRegID != "" && TaxRegIDYN != null) uri += "&TaxRegID=" + TaxRegID; uri += "&Page=" + Integer.toString(Page); uri += "&PerPage=" + Integer.toString(PerPage); uri += "&Order=" + Order; return httpget(uri, CorpNum, UserID, HTTaxinvoiceSearchResult.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#Search(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.Integer, java.lang.Integer, java.lang.String, java.lang.String)
@Override public HTTaxinvoiceSummary summary(String CorpNum, String JobID, String[] Type, String[] TaxType, String[] PurposeType, String TaxRegIDYN, String TaxRegIDType, String TaxRegID) throws PopbillException { return summary(CorpNum, JobID, Type, TaxType, PurposeType, TaxRegIDYN, TaxRegIDType, TaxRegID, null); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#Summary(java.lang.String, java.lang.String, java.lang.String[], java.lang.String[], java.lang.String[], java.lang.Boolean, java.lang.String, java.lang.String[])
@Override public HTTaxinvoiceSummary summary(String CorpNum, String JobID, String[] Type, String[] TaxType, String[] PurposeType, String TaxRegIDYN, String TaxRegIDType, String TaxRegID, String UserID) throws PopbillException { if (JobID.length() != 18) throw new PopbillException(-99999999, "작업아이디가 올바르지 않았습니다."); String uri = "/HomeTax/Taxinvoice/" + JobID + "/Summary"; uri += "?Type=" + Arrays.toString(Type) .replaceAll("\\[|\\]|\\s", ""); uri += "&TaxType=" + Arrays.toString(TaxType) .replaceAll("\\[|\\]|\\s", ""); uri += "&PurposeType=" + Arrays.toString(PurposeType) .replaceAll("\\[|\\]|\\s", ""); if (TaxRegIDType != "" && TaxRegIDType != null) uri += "&TaxRegIDType=" + TaxRegIDType; if (TaxRegIDYN != "" && TaxRegIDYN != null) uri += "&TaxRegIDYN=" + TaxRegIDYN; if (TaxRegID != "" && TaxRegID != null) uri += "&TaxRegID=" + TaxRegID; return httpget(uri, CorpNum, UserID, HTTaxinvoiceSummary.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#Summary(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)
@Override public HTTaxinvoice getTaxinvoice(String CorpNum, String NTSConfirmNum) throws PopbillException { return getTaxinvoice(CorpNum, NTSConfirmNum, null); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#GetTaxinvoice(java.lang.String, java.lang.String)
@Override public HTTaxinvoice getTaxinvoice(String CorpNum, String NTSConfirmNum, String UserID) throws PopbillException { if ( NTSConfirmNum.length() != 24 ) throw new PopbillException(-99999999, "국세청승인번호가 올바르지 않았습니다."); return httpget("/HomeTax/Taxinvoice/" +NTSConfirmNum, CorpNum, UserID, HTTaxinvoice.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#GetTaxinvoice(java.lang.String, java.lang.String, java.lang.String)
@Override public HTTaxinvoiceXMLResponse getXML(String CorpNum, String NTSConfirmNum) throws PopbillException { return getXML(CorpNum, NTSConfirmNum, null); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#GetXML(java.lang.String, java.lang.String)
@Override public HTTaxinvoiceXMLResponse getXML(String CorpNum, String NTSConfirmNum, String UserID) throws PopbillException { if ( NTSConfirmNum.length() != 24 ) throw new PopbillException(-99999999, "국세청승인번호가 올바르지 않았습니다."); return httpget("/HomeTax/Taxinvoice/" +NTSConfirmNum+"?T=xml", CorpNum, UserID, HTTaxinvoiceXMLResponse.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#GetXML(java.lang.String, java.lang.String, java.lang.String)
@Override public FlatRateState getFlatRateState(String CorpNum, String UserID) throws PopbillException { return httpget("/HomeTax/Taxinvoice/Contract", CorpNum, UserID, FlatRateState.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#GetFlatRateState(java.lang.String, java.lang.String)
@Override public String getPopUpURL(String CorpNum, String NTSConfirmNum) throws PopbillException { if ( NTSConfirmNum.length() != 24 ) throw new PopbillException(-99999999, "국세청승인번호가 올바르지 않았습니다."); URLResponse response = httpget("/HomeTax/Taxinvoice/" +NTSConfirmNum+"/PopUp", CorpNum, null, URLResponse.class); return response.url; }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#getPopUpURL(java.lang.String, java.lang.String)
public Response registDeptUser(String corpNum, String deptUserID, String deptUserPWD) throws PopbillException{ if (corpNum == null || corpNum.isEmpty()) throw new PopbillException(-99999999, "연동회원 사업자번호(corpNum)가 입력되지 않았습니다."); if (deptUserID == null || deptUserID.isEmpty()) throw new PopbillException(-99999999, "홈택스 부서사용자 계정 아이디(deptUserID)가 입력되지 않았습니다."); if (deptUserPWD == null || deptUserPWD.isEmpty()) throw new PopbillException(-99999999, "홈택스 부서사용자 계정 비밀번호(deptUserPWD)가 입력되지 않았습니다."); DeptRequest request = new DeptRequest(); request.id = deptUserID; request.pwd = deptUserPWD; String PostData = toJsonString(request); return httppost("/HomeTax/Taxinvoice/DeptUser", corpNum, PostData, null, Response.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#registDeptUser(java.lang.String, java.lang.String, java.lang.String)
public Response checkDeptUser(String CorpNum) throws PopbillException{ if (CorpNum == null || CorpNum.isEmpty()) throw new PopbillException(-99999999, "연동회원 사업자번호(CorpNum)가 입력되지 않았습니다."); return httpget("/HomeTax/Taxinvoice/DeptUser", CorpNum, null, Response.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#checkDeptUser(java.lang.String, java.lang.String)
public Response checkLoginDeptUser(String CorpNum) throws PopbillException{ if (CorpNum == null || CorpNum.isEmpty()) throw new PopbillException(-99999999, "연동회원 사업자번호(CorpNum)가 입력되지 않았습니다."); return httpget("/HomeTax/Taxinvoice/DeptUser/Check", CorpNum, null, Response.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#checkLoginDeptUser(java.lang.String)
public Response deleteDeptUser(String corpNum) throws PopbillException{ if (corpNum == null || corpNum.isEmpty()) throw new PopbillException(-99999999, "연동회원 사업자번호(corpNum)가 입력되지 않았습니다."); return httppost("/HomeTax/Taxinvoice/DeptUser", corpNum, null, null, "DELETE", Response.class); }
/* (non-Javadoc) @see com.popbill.api.HTTaxinvoiceService#deleteDeptUser(java.lang.String)
public static Face createTriangle(Vertex v0, Vertex v1, Vertex v2, double minArea) { Face face = new Face(); HalfEdge he0 = new HalfEdge(v0, face); HalfEdge he1 = new HalfEdge(v1, face); HalfEdge he2 = new HalfEdge(v2, face); he0.prev = he2; he0.next = he1; he1.prev = he0; he1.next = he2; he2.prev = he1; he2.next = he0; face.he0 = he0; // compute the normal and offset face.computeNormalAndCentroid(minArea); return face; }
Constructs a triangule Face from vertices v0, v1, and v2. @param v0 first vertex @param v1 second vertex @param v2 third vertex
public double distanceToPlane(Point3d p) { return normal.x * p.x + normal.y * p.y + normal.z * p.z - planeOffset; }
Computes the distance from a point p to the plane of this face. @param p the point @return distance from the point to the plane
public HalfEdge findEdge(Vertex vt, Vertex vh) { HalfEdge he = he0; do { if (he.head() == vh && he.tail() == vt) { return he; } he = he.next; } while (he != he0); return null; }
Finds the half-edge within this face which has tail <code>vt</code> and head <code>vh</code>. @param vt tail point @param vh head point @return the half-edge, or null if none is found.
public HalfEdge getEdge(int i) { HalfEdge he = he0; while (i > 0) { he = he.next; i--; } while (i < 0) { he = he.prev; i++; } return he; }
Gets the i-th half-edge associated with the face. @param i the half-edge index, in the range 0-2. @return the half-edge
public double areaSquared(HalfEdge hedge0, HalfEdge hedge1) { Point3d p0 = hedge0.tail().pnt; Point3d p1 = hedge0.head().pnt; Point3d p2 = hedge1.head().pnt; double dx1 = p1.x - p0.x; double dy1 = p1.y - p0.y; double dz1 = p1.z - p0.z; double dx2 = p2.x - p0.x; double dy2 = p2.y - p0.y; double dz2 = p2.z - p0.z; double x = dy1 * dz2 - dz1 * dy2; double y = dz1 * dx2 - dx1 * dz2; double z = dx1 * dy2 - dy1 * dx2; return x * x + y * y + z * z; }
return the squared area of the triangle defined by the half edge hedge0 and the point at the head of hedge1. @param hedge0 @param hedge1 @return
public String getPartnerURL(String CorpNum, String TOGO) throws PopbillException{ try { return getTokenbuilder().getPartnerURL( this.getSessionToken(CorpNum, null), TOGO); } catch (LinkhubException le) { throw new PopbillException(le); } }
/* (non-Javadoc) @see com.popbill.api.BaseService#getPartnerURL(java.lang.String, java.lang.String)
@Override public double getBalance(String CorpNum) throws PopbillException { try { return getTokenbuilder().getBalance( this.getSessionToken(CorpNum, null)); } catch (LinkhubException le) { throw new PopbillException(le); } }
/* (non-Javadoc) @see com.popbill.api.BaseService#getBalance(java.lang.String)
@Override public Response joinMember(JoinForm joinInfo) throws PopbillException { String postData = toJsonString(joinInfo); return httppost("/Join", null, postData, null, Response.class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#joinMember(com.popbill.api.JoinForm)
@Override public Response checkIsMember(String CorpNum, String LinkID) throws PopbillException { return httpget("/Join?CorpNum=" + CorpNum + "&LID=" + LinkID, null, null, Response.class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#checkIsMember(java.lang.String, java.lang.String)
@Override public ContactInfo[] listContact(String CorpNum) throws PopbillException { return httpget("/IDs", CorpNum, null, ContactInfo[].class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#listContact(java.lang.String, java.lang.String)
@Override public ContactInfo[] listContact(String CorpNum, String UserID) throws PopbillException { return httpget("/IDs", CorpNum, UserID, ContactInfo[].class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#listContact(java.lang.String, java.lang.String)
@Override public Response updateContact(String CorpNum, ContactInfo contactInfo, String UserID) throws PopbillException { String postData = toJsonString(contactInfo); return httppost("/IDs", CorpNum, postData, UserID, Response.class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#updateContactMember(java.lang.String, com.popbill.api.ContactInfo, java.lang.String)
@Override public Response checkID(String CheckID) throws PopbillException { return httpget("/IDCheck?ID="+CheckID, null, null, Response.class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#checkID(java.lang.String)
@Override public CorpInfo getCorpInfo(String CorpNum) throws PopbillException { return httpget("/CorpInfo", CorpNum, null, CorpInfo.class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#getCorpInfo(java.lang.String, java.lang.String)
@Override public CorpInfo getCorpInfo(String CorpNum, String UserID) throws PopbillException { return httpget("/CorpInfo", CorpNum, UserID, CorpInfo.class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#getCorpInfo(java.lang.String, java.lang.String)
@Override public Response updateCorpInfo(String CorpNum, CorpInfo corpInfo) throws PopbillException { String postData = toJsonString(corpInfo); return httppost("/CorpInfo", CorpNum, postData, null, Response.class); }
/* (non-Javadoc) @see com.popbill.api.BaseService#updateCorpInfo(java.lang.String, com.popbill.api.CorpInfo, java.lang.String)
protected <T> T fromJsonString(String json, Class<T> clazz) { return _gsonParser.fromJson(json, clazz); }
Convert JsonString to Object of Clazz @param json @param clazz @return Object of Clazz
public LuaScript endScript(LuaScriptConfig config) { if (!endsWithReturnStatement()) { add(new LuaAstReturnStatement()); } String scriptText = buildScriptText(); return new BasicLuaScript(scriptText, config); }
End building the script @param config the configuration for the script to build @return the new {@link LuaScript} instance
public LuaScript endScriptReturn(LuaValue value, LuaScriptConfig config) { add(new LuaAstReturnStatement(argument(value))); String scriptText = buildScriptText(); return new BasicLuaScript(scriptText, config); }
End building the script, adding a return value statement @param config the configuration for the script to build @param value the value to return @return the new {@link LuaScript} instance
public LuaPreparedScript endPreparedScript(LuaScriptConfig config) { if (!endsWithReturnStatement()) { add(new LuaAstReturnStatement()); } String scriptText = buildScriptText(); ArrayList<LuaKeyArgument> keyList = new ArrayList<>(keyArg2AstArg.keySet()); ArrayList<LuaValueArgument> argvList = new ArrayList<>(valueArg2AstArg.keySet()); if (config.isThreadSafe()) { return new ThreadSafeLuaPreparedScript(scriptText, keyList, argvList, config); } else { return new BasicLuaPreparedScript(scriptText, keyList, argvList, config); } }
End building the prepared script @param config the configuration for the script to build @return the new {@link LuaPreparedScript} instance
public LuaPreparedScript endPreparedScriptReturn(LuaValue value, LuaScriptConfig config) { add(new LuaAstReturnStatement(argument(value))); return endPreparedScript(config); }
End building the prepared script, adding a return value statement @param value the value to return @param config the configuration for the script to build @return the new {@link LuaPreparedScript} instance
private synchronized static Cluster getCluster(URI baseUrl, String[] personalities) throws IOException { final Entry<URI, Set<String>> key = Maps.immutableEntry(baseUrl, (Set<String>)ImmutableSet.copyOf(personalities)); Cluster result = CLUSTERS.get(key); if (result != null) { return result; } result = new Cluster(EmbeddedPostgreSQL.start()); final DBI dbi = new DBI(result.getPg().getTemplateDatabase()); final Migratory migratory = new Migratory(new MigratoryConfig() {}, dbi, dbi); migratory.addLocator(new DatabasePreparerLocator(migratory, baseUrl)); final MigrationPlan plan = new MigrationPlan(); int priority = 100; for (final String personality : personalities) { plan.addMigration(personality, Integer.MAX_VALUE, priority--); } migratory.dbMigrate(plan); result.start(); CLUSTERS.put(key, result); return result; }
Each schema set has its own database cluster. The template1 database has the schema preloaded so that each test case need only create a new database and not re-invoke Migratory.
public Config getTweakedConfig(Config config, String dbModuleName) { return Config.getOverriddenConfig(config, new MapConfiguration(getConfigurationTweak(dbModuleName))); }
Override a {@link Config} to set <code>ness.db.[db-name].uri</code> to a unique database in the cluster.
public ImmutableMap<String, String> getConfigurationTweak(String dbModuleName) { final DbInfo db = cluster.getNextDb(); return ImmutableMap.of("ness.db." + dbModuleName + ".uri", getJdbcUri(db), "ness.db." + dbModuleName + ".ds.user", db.user); }
Return configuration tweaks in a format appropriate for ness-jdbc DatabaseModule.
public long length() { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.exists(getKey()) ? jedis.hlen(getKey()) : 0; } }); }
Get the length of the map (i.e. the number of keys).<br> This is similar to {@link #size()} but is preferred since redis' capacity supports long typed values @return the number of keys
public boolean putIfMissing(final String field, final String value) { return doWithJedis(new JedisCallable<Boolean>() { @Override public Boolean call(Jedis jedis) { return jedis.hsetnx(getKey(), field, value) != 0; } }); }
Put <code>value</code> associated to <code>field</code>, only if field does not yet exist. @param field the field @param value the value @return <code>true</code> if the value was set, <code>false</code> otherwise
public long remove(final String... fields) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.hdel(getKey(), fields); } }); }
Remove multiple fields from the map @param fields the fields to remove @return the number of fields removed
@Override public CorpState CheckCorpNum(String MemberCorpNum, String CheckCorpNum) throws PopbillException { return httpget("/CloseDown?CN=" + CheckCorpNum, MemberCorpNum, null, CorpState.class); }
/* (non-Javadoc) @see com.popbill.api.CloseDownService#CheckCorpNum
@Override public CorpState[] CheckCorpNum(String MemberCorpNum, String[] CorpNumList) throws PopbillException { String PostData = toJsonString(CorpNumList); return httppost("/CloseDown", MemberCorpNum,PostData, null, CorpState[].class); }
/* (non-Javadoc) @see com.popbill.api.CloseDownService#CheckCorpNum
@Override public void delete(final String id) { if (!StringUtils.isEmpty(id)) { doDelete(id); notifyDeleted(id); } }
/* (non-Javadoc) @see com.arakelian.dao.Dao#delete(java.lang.String)
@Override public void delete(final T value) { if (value != null) { final String id = value.getId(); if (!StringUtils.isEmpty(id)) { doDelete(id); notifyDeleted(value); } } }
/* (non-Javadoc) @see com.arakelian.dao.Dao#delete(com.arakelian.dao.feature.HasId)
@Override public void deleteAll(final Collection<T> values) { if (values == null || values.size() == 0) { return; } // we need a List of values to partition final List<T> valuesList; if (values instanceof List) { valuesList = (List<T>) values; } else { valuesList = Lists.newArrayList(values); } // process values in groups of <partition size> for (final List<T> partition : Lists.partition(valuesList, config.getPartitionSize())) { doDeleteAllValues(partition); for (final T value : partition) { notifyDeleted(value); } } }
/* (non-Javadoc) @see com.arakelian.dao.Dao#deleteAll(java.util.Collection)
@Override public void deleteAll(final String... ids) { if (ids == null || ids.length == 0) { return; } // process ids in groups of <partition size> final ArrayList<String> list = Lists.newArrayList(ids); for (final List<String> partition : Lists.partition(list, config.getPartitionSize())) { doDeleteAllIds(partition); for (final String id : partition) { notifyDeleted(id); } } }
/* (non-Javadoc) @see com.arakelian.dao.Dao#deleteAll(java.lang.Object[])
@Override public void putAll(final Collection<T> values) { if (values == null || values.size() == 0) { return; } for (final T value : values) { put(value); } }
/* (non-Javadoc) @see com.arakelian.dao.Dao#putAll(java.util.Collection)
@Override public void putAll(final T[] values) { if (values == null || values.length == 0) { return; } for (final T value : values) { put(value); } }
/* (non-Javadoc) @see com.arakelian.dao.Dao#putAll(com.arakelian.dao.feature.HasId[])
private static ExcelConfig getEasyExcel(String xmlPath) { ExcelConfig easyExcel = cache.get(xmlPath); if (easyExcel == null) { easyExcel = XmlConfig.getXmlConfig(xmlPath); } if (easyExcel == null) { throw new RuntimeException("无法获取xml配置文件!"); } if (easyExcel.getCache() == null || easyExcel.getCache()) { cache.put(xmlPath, easyExcel); } return easyExcel; }
获取xml配置对象 @param xmlPath xml完整路径 @return xml配置对象
public static List<?> xls2List(String xmlPath, InputStream inputStream) throws Exception { Workbook wb = null; List<?> list = null; try { wb = Workbook.getWorkbook(inputStream); list = workbook2List(xmlPath, wb); } catch (Exception e) { throw new Exception("转换xls出错:" + e.getMessage()); } finally { if (wb != null) { wb.close(); } } return list; }
导入xml到List @param xmlPath xml完整路径 @param inputStream xls文件流 @return List对象 @throws Exception
public static List<?> workbook2List(String xmlPath, Workbook wb) throws Exception { //获取配置文件 ExcelConfig config = getEasyExcel(xmlPath); return workbook2List(config, wb); }
workbook转换为list @param xmlPath @param wb @return @throws Exception
public static List<?> workbook2List(ExcelConfig config, Workbook wb) throws Exception { String[] names = config.getNames(); String[] types = config.getTypes(); Field key = config.getKey(); List<Object> list = new ArrayList<Object>(); Sheet sheet = wb.getSheet(config.getSheetNum()); int length = sheet.getColumns() < names.length ? sheet.getColumns() : names.length; //计算行数 int rowLength = sheet.getRows() < config.getMaxRow() ? sheet.getRows() : (config.getMaxRow() > 0 ? (config.getMaxRow() + config.getStartRow()) : sheet.getRows()); for (int i = config.getStartRow(); i < rowLength; i++) { //Map类型要特殊处理 Class clazz = Class.forName(config.getClazz()); Object obj = null; if (Map.class.isAssignableFrom(clazz)) { obj = new HashMap(); } else { obj = clazz.newInstance(); } for (int j = 0; j < length; j++) { setValue(obj, names[j], types[j], sheet.getCell(j, i)); } //checkKey if (key != null) { //当主键为空时,不在继续读取excel if (key.get(obj) == null || "".equals(String.valueOf(key.get(obj)))) { break; } } list.add(obj); } return list; }
workbook转换为list @param config 配置 @param wb excel @return @throws Exception
private static Object getCellValue(Cell cell) throws Exception { Object value = null; if (cell instanceof ErrorCell) { value = null; } else if (cell instanceof LabelCell) { value = ((LabelCell) cell).getString(); } else if (cell instanceof NumberCell) { value = ((NumberCell) cell).getValue(); } else if (cell instanceof DateCell) { value = ((DateCell) cell).getDate(); } else if (cell instanceof BooleanCell) { value = ((BooleanCell) cell).getValue(); } /*else if (cell instanceof FormulaCell) { value = ((FormulaCell) cell).getFormula(); }*/ else { value = cell.getContents(); } return value; }
获取单元格的数据 @param cell @return @throws Exception
private static void setValue(Object obj, String fieldName, String type, Cell cell) throws Exception { Object val = null; Object v = getCellValue(cell); if (v == null) { //不处理 } else if (Object.class.getCanonicalName().equals(type)) { //类型一致的直接使用 val = v; } else if (v.getClass().getName().equals(type)) { //类型一致的直接使用 val = v; } else { //类型不一致进行转换 String value = v.toString(); if (value != null && !value.trim().equals("")) { value = value.trim(); /** * 对类型进行转换,支持int,long,float,double,boolean,Integer,Long,Double,Float,Date,String */ if (type.equals("int")) { val = new BigDecimal(value).intValue(); } else if (type.equals("long")) { val = new BigDecimal(value).longValue(); } else if (type.equals("float")) { val = new BigDecimal(value).floatValue(); } else if (type.equals("double")) { val = new BigDecimal(value).doubleValue(); } else if (type.equals("boolean")) { val = Boolean.parseBoolean(value); } else { Class clazz = Class.forName(type); if (!clazz.equals(String.class)) { if (clazz.equals(Date.class)) { val = DateUtil.smartFormat(value); } else if (clazz.equals(Integer.class)) { val = new BigDecimal(value).intValue(); } else if (clazz.equals(Long.class)) { val = new BigDecimal(value).longValue(); } else if (clazz.equals(Float.class)) { val = new BigDecimal(value).floatValue(); } else if (clazz.equals(Double.class)) { val = new BigDecimal(value).doubleValue(); } else if (clazz.equals(Boolean.class)) { val = Boolean.parseBoolean(value); } else if (clazz.equals(BigDecimal.class)) { val = new BigDecimal(value); } } else { val = value; } } } } Field field = FieldUtil.getField(obj, fieldName); if (field != null) { field.set(obj, val); } }
跟对象obj的某个field赋值value @param obj 属性对象 @param fieldName 字段名 @param cell 单元格 @throws Exception
public static boolean list2Xls(List<?> list, String xmlPath, String filePath, String fileName) throws Exception { //创建目录 File file = new File(filePath); if (!(file.exists())) { if (!file.mkdirs()) { throw new RuntimeException("创建导出目录失败!"); } } try { ExcelConfig config = getEasyExcel(xmlPath); return list2Xls(config, list, filePath, fileName); } catch (Exception e1) { return false; } }
导出list对象到excel @param list 导出的list @param xmlPath xml完整路径 @param filePath 保存xls路径 @param fileName 保存xls文件名 @return 处理结果,true成功,false失败 @throws Exception
public static boolean list2Xls(List<?> list, String xmlPath, OutputStream outputStream) throws Exception { try { ExcelConfig config = getEasyExcel(xmlPath); return list2Xls(config, list, outputStream); } catch (Exception e1) { return false; } }
导出list对象到excel @param list 导出的list @param xmlPath xml完整路径 @param outputStream 输出流 @return 处理结果,true成功,false失败 @throws Exception
public static boolean list2Xls(ExcelConfig config, List<?> list, String filePath, String fileName) throws Exception { //创建目录 File file = new File(filePath); if (!(file.exists())) { if (!file.mkdirs()) { throw new RuntimeException("创建导出目录失败!"); } } OutputStream outputStream = null; try { if (!fileName.toLowerCase().endsWith(EXCEL)) { fileName += EXCEL; } File excelFile = new File(filePath + "/" + fileName); outputStream = new FileOutputStream(excelFile); return list2Xls(config, list, outputStream); } catch (Exception e1) { return false; } finally { if(outputStream != null){ outputStream.close(); } } }
导出list对象到excel @param config 配置 @param list 导出的list @param filePath 保存xls路径 @param fileName 保存xls文件名 @return 处理结果,true成功,false失败 @throws Exception
public static boolean list2Xls(ExcelConfig config, List<?> list, OutputStream outputStream) throws Exception { try { String[] header = config.getHeaders(); String[] names = config.getNames(); String[] values; WritableWorkbook wb = Workbook.createWorkbook(outputStream); String sheetName = (config.getSheet() != null && !config.getSheet().equals("")) ? config.getSheet() : ("sheet" + config.getSheetNum()); WritableSheet sheet = wb.createSheet(sheetName, 0); int row = 0; int column = 0; int rowadd = 0; //写入标题 if (config.getHeader()) { for (column = 0; column < header.length; column++) { sheet.addCell(new Label(column, row + rowadd, header[column])); if (config.getColumn(column).getWidth() != null) { sheet.setColumnView(column, config.getColumn(column).getWidth() / 7); } } rowadd++; } //写入内容//行 for (row = 0; row < list.size(); row++) { Object rowData = list.get(row); values = getObjValues(rowData, names); //列 for (column = 0; column < values.length; column++) { sheet.addCell(new Label(column, row + rowadd, values[column])); } } wb.write(); wb.close(); } catch (Exception e1) { return false; } return true; }
导出list对象到excel @param config 配置 @param list 导出的list @param outputStream 输出流 @return 处理结果,true成功,false失败 @throws Exception
private static String[] getObjValues(Object source, String... fieldnames) throws Exception { String[] results = new String[fieldnames.length]; Field field; String value; Object obj; for (int i = 0; i < fieldnames.length; i++) { field = FieldUtil.getField(source, fieldnames[i]); if (field == null) { continue; } obj = field.get(source); if (obj == null) { value = ""; } else if (obj instanceof Date) { value = DateUtil.smartFormat((Date) obj); } else { value = String.valueOf(obj); } results[i] = value; } return results; }
获取对象指定字段值 @param source 对象 @param fieldnames 属性名数组 @return 对象的字符串数组,和属性名对应 @throws Exception
public static String smartFormat(Date date) { String dateStr = null; if (date == null) { dateStr = ""; } else { try { dateStr = formatDate(date, Y_M_D_HMS); //时分秒 if (dateStr.endsWith(" 00:00:00")) { dateStr = dateStr.substring(0, 10); } //时分 else if (dateStr.endsWith("00:00")) { dateStr = dateStr.substring(0, 16); } //秒 else if (dateStr.endsWith(":00")) { dateStr = dateStr.substring(0, 16); } } catch (Exception ex) { throw new IllegalArgumentException("转换日期失败: " + ex.getMessage(), ex); } } return dateStr; }
智能转换日期 @param date @return
public static Date smartFormat(String text) { Date date = null; try { if (text == null || text.length() == 0) { date = null; } else { int length = text.length(); if (text.indexOf("-") > 0) { if (length == 10) { date = formatStringToDate(text, Y_M_D); } else if (length == 16) { date = formatStringToDate(text, Y_M_D_HM); } else if (length == 19) { date = formatStringToDate(text, Y_M_D_HMS); } else { throw new IllegalArgumentException("日期长度不符合要求!"); } } else if (text.indexOf("/") > 0) { if (length == 10) { date = formatStringToDate(text, ymd); } else if (length == 16) { date = formatStringToDate(text, ymd_HM); } else if (length == 19) { date = formatStringToDate(text, ymd_HMS); } else { throw new IllegalArgumentException("日期长度不符合要求!"); } } else { if (length == 10) { date = formatStringToDate(text, YMD); } else if (length == 13) { date = new Date(Long.parseLong(text)); } else if (length == 16) { date = formatStringToDate(text, YMDHM); } else if (length == 19) { date = formatStringToDate(text, YMDHMS); } else { throw new IllegalArgumentException("日期长度不符合要求!"); } } } } catch (Exception e) { throw new IllegalArgumentException("日期格式错误!"); } return date; }
智能转换日期 @param text @return
public static String formatDate(Date argDate, String argFormat) throws Exception { if (argDate == null) { throw new Exception("参数[日期]不能为空!"); } if (argFormat == null || argFormat.length() == 0) { argFormat = Y_M_D; } SimpleDateFormat sdfFrom = new SimpleDateFormat(argFormat); return sdfFrom.format(argDate).toString(); }
格式化日期格式 @param argDate @param argFormat @return 格式化后的日期字符串
public static Date formatStringToDate(String argDateStr, String argFormat) throws Exception { if (argDateStr == null || argDateStr.trim().length() < 1) { throw new Exception("参数[日期]不能为空!"); } String strFormat = argFormat; if (strFormat == null || strFormat.length() == 0) { strFormat = Y_M_D; if (argDateStr.length() > 16) { strFormat = Y_M_D_HMS; } else if (argDateStr.length() > 10) { strFormat = Y_M_D_HM; } } SimpleDateFormat sdfFormat = new SimpleDateFormat(strFormat); //严格模式 sdfFormat.setLenient(false); try { return sdfFormat.parse(argDateStr); } catch (ParseException e) { throw new Exception(e); } }
把字符串格式化成日期 @param argDateStr @param argFormat @return
public BuilderType assign(LuaLocal local, LuaValue value) { add(assignment(local(local.getName()), argument(value))); return thisBuilder(); }
Assign a value to an existing local @param local the local to which to assign the value @param value the value to assign @return this builder
public BuilderType assign(LuaLocal local, String value) { add(assignment(local(local.getName()), stringValue(value))); return thisBuilder(); }
Assign a value to an existing local @param local the local to which to assign the value @param value the value to assign @return this builder
@Override public BuilderType select(int index) { add(redisCallStatement("SELECT", arguments(intValue(index)))); return thisBuilder(); }
*** Jedis Commands ***
public String spacingText(String text) { // CJK and quotes Matcher cqMatcher = CJK_QUOTE.matcher(text); text = cqMatcher.replaceAll("$1 $2"); Matcher qcMatcher = QUOTE_CJK.matcher(text); text = qcMatcher.replaceAll("$1 $2"); Matcher fixQuoteMatcher = FIX_QUOTE.matcher(text); text = fixQuoteMatcher.replaceAll("$1$3$5"); // CJK and brackets String oldText = text; Matcher cbcMatcher = CJK_BRACKET_CJK.matcher(text); String newText = cbcMatcher.replaceAll("$1 $2 $4"); text = newText; if (oldText.equals(newText)) { Matcher cbMatcher = CJK_BRACKET.matcher(text); text = cbMatcher.replaceAll("$1 $2"); Matcher bcMatcher = BRACKET_CJK.matcher(text); text = bcMatcher.replaceAll("$1 $2"); } Matcher fixBracketMatcher = FIX_BRACKET.matcher(text); text = fixBracketMatcher.replaceAll("$1$3$5"); // CJK and hash Matcher chMatcher = CJK_HASH.matcher(text); text = chMatcher.replaceAll("$1 $2"); Matcher hcMatcher = HASH_CJK.matcher(text); text = hcMatcher.replaceAll("$1 $3"); // CJK and ANS Matcher caMatcher = CJK_ANS.matcher(text); text = caMatcher.replaceAll("$1 $2"); Matcher acMatcher = ANS_CJK.matcher(text); text = acMatcher.replaceAll("$1 $2"); return text; }
Performs a paranoid text spacing on {@code text}. @param text the string you want to process, must not be {@code null}. @return a comfortable and readable version of {@code text} for paranoiac.
public void spacingFile(File inputFile, File outputFile) throws IOException { // TODO: support charset FileReader fr = new FileReader(inputFile); BufferedReader br = new BufferedReader(fr); outputFile.getParentFile().mkdirs(); FileWriter fw = new FileWriter(outputFile, false); BufferedWriter bw = new BufferedWriter(fw); try { String line = br.readLine(); // readLine() do not contain newline char while (line != null) { line = spacingText(line); // TODO: keep file's raw newline char from difference OS platform bw.write(line); bw.newLine(); line = br.readLine(); } } finally { br.close(); // 避免 writer 沒有實際操作就 close(),產生一個空檔案 if (bw != null) { bw.close(); } } }
Performs a paranoid text spacing on {@code inputFile} and generate a new file {@code outputFile}. @param inputFile an existing file to process, must not be {@code null}. @param outputFile the processed file, must not be {@code null}. @throws IOException if an error occurs. @since 1.1.0
public long cardinality() { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zcard(getKey()); } }); }
Get the cardinality of the set (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 set
public Double score(final String member) { return doWithJedis(new JedisCallable<Double>() { @Override public Double call(Jedis jedis) { return jedis.zscore(getKey(), member); } }); }
Return the score of the specified element of the sorted set at key. @param member @return The score value or <code>null</code> if the element does not exist in the set.
public boolean add(final String member, final double score) { return doWithJedis(new JedisCallable<Boolean>() { @Override public Boolean call(Jedis jedis) { return jedis.zadd(getKey(), score, member) > 0; } }); }
Add an element assigned with its score @param member the member to add @param score the score to assign @return <code>true</code> if the set has been changed
public long addAll(final String... members) { Map<String, Double> scoredMembers = new HashMap<>(members.length); for (String member : members) { scoredMembers.put(member, scoreProvider.getScore(member)); } return addAll(scoredMembers); }
Adds to this set all of the elements in the specified members array (Uses the configured {@link ScoreProvider} for assigning scores) @param members the members to add @return the number of members actually added
public long addAll(final Map<String, Double> scoredMember) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zadd(getKey(), scoredMember); } }); }
Adds to this set all of the elements in the specified map of members and their score. @param scoredMember the members to add together with their scores @return the number of members actually added
public Long rank(final String member) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zrank(getKey(), member); } }); }
Returns the rank of member in the sorted set, with the scores ordered from low to high. The rank (or index) is 0-based, which means that the member with the lowest score has rank 0. @param member @return the rank of member, or <code>null</code> if the member does not exist
public Long rankReverse(final String member) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zrevrank(getKey(), member); } }); }
Returns the rank of member in the sorted set, with the scores ordered from high to low. The rank (or index) is 0-based, which means that the member with the highest score has rank 0. @param member @return the reversed rank of member, or <code>null</code> if the member does not exist
public Set<String> rangeByRank(final long start, final long end) { return doWithJedis(new JedisCallable<Set<String>>() { @Override public Set<String> call(Jedis jedis) { return jedis.zrange(getKey(), start, end); } }); }
Returns the specified range of elements in the sorted set. The elements are considered to be ordered from the lowest to the highest score. Lexicographical order is used for elements with equal score. Both start and stop are zero-based inclusive indexes. They can also be negative numbers indicating offsets from the end of the sorted set, with -1 being the last element of the sorted set. @param start @param end @return the range of elements
public Set<String> rangeByRankReverse(final long start, final long end) { return doWithJedis(new JedisCallable<Set<String>>() { @Override public Set<String> call(Jedis jedis) { return jedis.zrevrange(getKey(), start, end); } }); }
Returns the specified range of elements in the sorted set. The elements are considered to be ordered from the highest to the lowest score. Descending lexicographical order is used for elements with equal score. Both start and stop are zero-based inclusive indexes. They can also be negative numbers indicating offsets from the end of the sorted set, with -1 being the last element of the sorted set. @param start @param end @return the range of elements
public long removeRangeByRank(final long start, final long end) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zremrangeByRank(getKey(), start, end); } }); }
Removes all elements in the sorted set with rank between start and stop. Both start and stop are 0 -based indexes with 0 being the element with the lowest score. These indexes can be negative numbers, where they indicate offsets starting at the element with the highest score. For example: -1 is the element with the highest score, -2 the element with the second highest score and so forth. @param start @param end @return the number of elements removed.
public long countByLex(final LexRange lexRange) { return doWithJedis(new JedisCallable<Long>() { @Override public Long call(Jedis jedis) { return jedis.zlexcount(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 the number of elements in the sorted set with a value in the given range. @param lexRange @return the number of elements in the specified range.