private static void loadPropertyNamesValues( Class clazz, Object instance, List names, List values) { PropertyDescriptor pd; BeanInfo info = null; try { info = Introspector.getBeanInfo(clazz); } catch (IntrospectionException ex) { Err.error(ex); } PropertyDescriptor[] propertyDescriptors = info.getPropertyDescriptors(); for (int i = 0; i < propertyDescriptors.length; ++i) { pd = propertyDescriptors[i]; Object value = SelfReferenceUtils.invokeReadProperty(info, pd, instance, pd.getName()); if (value == null) { // Err.pr( "No property set for " + pd.getName() + " in " + clazz); } else { names.add(pd.getName()); values.add(value); } } if (names.isEmpty()) { Err.error("Strange that there are no properties with values in " + clazz); } }
private void init() { constructedTimes++; id = constructedTimes; Err.pr("####### Have created DebugList " + id); if (id == 0) { Err.stack(); } }
private boolean dealiCareCheckResult(Err err) { // 如果crs是“TRUE”,则为iCare自核保通过,否则为核保不通过。 if (err.getErr().contains("TRUE")) { return true; } return false; }
/** Should not be used directly by Strandz. See package org.strandz.core.info.convert */ public static String _getText(Object comp) { String result = null; Err.pr(SdzNote.DONT_USE_FROM_STRANDZ, "Don't use"); if (comp instanceof JComponent) { if (comp instanceof JTextComponent) { result = ((JTextComponent) comp).getText(); } else if (comp instanceof JLabel) { result = ((JLabel) comp).getText(); } else { Err.error( "ComponentUtils.getText(), not yet support JComponent of type " + comp.getClass()); } } else { Err.error("ComponentUtils.getText(), not yet support " + comp.getClass()); } return result; }
private boolean isOnSale(String contplancode, Err err) { String sql = "select count(1) from ledcode where codetype = 'JDSale' and code = '" + contplancode + "'"; if ("1".equals(new ExeSQL().getOneValue(sql))) { return true; } err.setErr("此产品未开始销售!"); return false; }
/** * Should not be used directly by Strandz. See package org.strandz.core.info.convert This must * come out as Strandz needs control over assignment * * @param comp * @param txt */ public static void _setText(Object comp, Object txt) { Err.pr(SdzNote.DONT_USE_FROM_STRANDZ, "Don't use"); if (comp instanceof JComponent) { String s = null; if (txt != null) { s = txt.toString(); } if (comp instanceof JTextComponent) { ((JTextComponent) comp).setText(s); } else if (comp instanceof JLabel) { ((JLabel) comp).setText(s); } else { Err.error( "ComponentUtils.setText(), not yet support JComponent of type " + comp.getClass()); } } else { Err.error("ComponentUtils.setText(), not yet support " + comp.getClass()); } }
public static boolean hasEditableMethod(Object comp) { boolean result = true; String methodName = "isEditable"; Class controlClass = comp.getClass(); try { controlClass.getMethod(methodName, (Class[]) null); } catch (NoSuchMethodException ex1) { result = false; } catch (Exception ex2) { Err.error("Missing method " + methodName + " from " + controlClass + ", ex: " + ex2); } return result; }
public static String getName(Object comp) { String result; Method getNameControlMethod = null; String methodName = "getName"; Class controlClass = comp.getClass(); try { getNameControlMethod = controlClass.getMethod(methodName, (Class[]) null); } catch (Exception ex) { Err.error("Missing method " + methodName + " from " + controlClass); } result = (String) SelfReferenceUtils.invoke(comp, getNameControlMethod); return result; }
public static void setEditable(Object comp, boolean b) { Class[] args1 = new Class[1]; args1[0] = Boolean.TYPE; Method setEditableControlMethod = null; String methodName = "setEditable"; Class controlClass = comp.getClass(); try { setEditableControlMethod = controlClass.getMethod(methodName, args1); } catch (Exception ex) { Err.error("Missing method " + methodName + " from " + controlClass); } SelfReferenceUtils.invoke(comp, setEditableControlMethod, Boolean.valueOf(b)); }
public static boolean controlNameIsUniqueIn(String name, List controls) { boolean result = false; if (name == null) { Err.error("controlNameIsUniqueIn() cannot be called with a null name"); } int timesFound = 0; for (Iterator iter = controls.iterator(); iter.hasNext(); ) { Component element = (Component) iter.next(); String elementName = element.getName(); if (elementName != null) { if (name.equals(elementName)) { timesFound++; } } } if (timesFound == 1) { result = true; } else if (timesFound == 0) { Err.error("This method assumes that <" + name + "> exists at least once"); } return result; }
private boolean CheckPrem( com.sinosoft.ec.webservices.jd.pojo.hebaoRequest.Package rp, com.sinosoft.ec.webservices.jd.pojo.hebaoResponse.Package rsp, Err err) { String fs = "M".equals(rp.getRequest().getOrder().getPaymentMethod()) ? "2" : "1"; BigDecimal f = new BigDecimal(fs); BigDecimal icareprem = u.caculate(rp).multiply(f); BigDecimal jdprem = new BigDecimal(rp.getRequest().getOrder().getTotalPrice()); System.out.println("JDPrem:" + jdprem); if (!icareprem.equals(jdprem)) { err.setErr("发布价格有误,正确的价格为" + (u.getYuanFromFen(String.valueOf(icareprem.intValue()))) + "元"); u.buildHeBaoEmptyRSP(rp, rsp, err); return false; } return true; }
/** * TODO - Think about reason are not going to ControlSignatures for this. Pros for not - * ControlSignatures is part of strandz core, whereas this is lgpl Pros for having in * ControlSignatures - Controls inside a table should be treated in exactly the same way as other * field controls. (This would require changes to info package). * * <p>Of course providing a service interface would be the answer, but changing info provides * inertia. Bugs because of differences will help the case for change. */ public static boolean isEditable(Object comp) { boolean result = false; Method isEditableControlMethod = null; String methodName = "isEditable"; Class controlClass = comp.getClass(); boolean noMethod = false; try { isEditableControlMethod = controlClass.getMethod(methodName, (Class[]) null); } catch (NoSuchMethodException ex1) { noMethod = true; } catch (Exception ex2) { Err.error("Missing method " + methodName + " from " + controlClass + ", ex: " + ex2); } if (!noMethod) { result = ((Boolean) SelfReferenceUtils.invoke(comp, isEditableControlMethod)).booleanValue(); } return result; }
public static void setText(Object comp, Object txt) { Class[] args1 = new Class[1]; args1[0] = String.class; Method setTextControlMethod = null; String methodName = "setText"; Class controlClass = comp.getClass(); try { setTextControlMethod = controlClass.getMethod(methodName, args1); } catch (Exception ex1) { args1[0] = Object.class; try { setTextControlMethod = controlClass.getMethod(methodName, args1); } catch (Exception ex2) { Err.error("Missing method " + methodName + " from " + controlClass); } } String s = null; if (txt != null) { s = txt.toString(); } SelfReferenceUtils.invoke(comp, setTextControlMethod, s); }
public boolean add(Object o) { boolean result = super.add(o); Err.pr("$$$ DEBUG add[@2]: <" + o + "> to " + id); // Err.stack(); return result; }
public boolean addAll(Collection c) { Err.pr("####### DEBUG addAll: <" + c + "> to " + id); return super.addAll(c); }
public static boolean equalsByProperties( JComponent component1, JComponent component2, WidgetClassifierI widgetClassifier) { ReasonNotEquals.addClassVisiting("pUtils.equalsByProperties()"); boolean result = true; List oneControls = getAllControls(component1); oneControls.add(0, component1); List twoControls = getAllControls(component2); twoControls.add(0, component2); if (oneControls.size() != twoControls.size()) { ReasonNotEquals.addReason( "got lists of controls of different sizes: " + oneControls.size() + " and " + twoControls.size()); Print.prList(oneControls, "oneControls"); Print.prList(twoControls, "twoControls"); result = false; } else { for (int i = 0; i < oneControls.size(); i++) { Container comp1 = (Container) oneControls.get(i); // Err.pr( "Observing a " + comp1.getClass()); Container comp2 = (Container) twoControls.get(i); if (comp1.getClass() != comp2.getClass()) { ReasonNotEquals.addReason( "first component is of type " + comp1.getClass() + " while second is of type " + comp2.getClass()); result = false; break; } else if (!Utils.equals(comp1.getName(), comp2.getName())) { ReasonNotEquals.addReason( "first component has name " + comp1.getName() + " while second has name " + comp2.getName()); result = false; break; } else if (widgetClassifier != null && !widgetClassifier.isAWidget( comp1.getClass())) { // If a comp1/comp2 is not a widget then end up here and we // won't examine // its properties // Err.pr( comp1.getClass() + " is not a widget: " + widgetClassifier.getReason()); } else { List propertyNamesOne = new ArrayList(); List propertyNamesTwo = new ArrayList(); List propertyValuesOne = new ArrayList(); List propertyValuesTwo = new ArrayList(); loadPropertyNamesValues(comp1.getClass(), comp1, propertyNamesOne, propertyValuesOne); loadPropertyNamesValues(comp2.getClass(), comp2, propertyNamesTwo, propertyValuesTwo); if (propertyNamesOne.size() != propertyValuesOne.size()) { Err.error("expect names and properties to be same size for " + comp1.getClass()); } else if (propertyNamesTwo.size() != propertyValuesTwo.size()) { Err.error("expect names and properties to be same size for " + comp2.getClass()); } else if (propertyNamesOne.size() != propertyNamesTwo.size()) { ReasonNotEquals.addReason( "there should be an equal number of properties in " + comp1.getClass() + " and " + comp2.getClass()); result = false; break; } else { // Err.pr( "Will be examining properties from a " + comp1.getClass() + " against " + // comp2.getClass()); for (int j = 0; j < propertyNamesOne.size(); j++) { String onePropName = (String) propertyNamesOne.get(j); String twoPropName = (String) propertyNamesTwo.get(j); if (!onePropName.equals(twoPropName)) { // If they are of thge same type, how could they possibly have // different property names, thus make this an error String txt = "expect property names to be equal, got " + onePropName + " and " + twoPropName; // ReasonNotEquals.addReason( txt); Err.error(txt); result = false; break; } else { Object onePropValue = propertyValuesOne.get(j); Object twoPropValue = propertyValuesTwo.get(j); boolean debug = false; /* if(onePropName.equals( "text")) { Err.debug(); debug = true; } */ if (onePropValue.getClass() != twoPropValue.getClass()) { Err.error( "Property values to be examining should be of the same type, got " + onePropValue.getClass().getName() + " and " + twoPropValue.getClass().getName()); result = false; break; } else if (!Utils.isSimple(onePropValue.getClass())) { // We only want to do value comparisons for simple types // Err.pr( "Not simple: <" + onePropValue + ">"); if (debug) { Err.error("Only supposed to be debugging on a simple property value"); } } else { if (debug) { Err.pr( "Doing cf between <" + onePropValue + "> and <" + twoPropValue + "> for " + onePropName + " in a " + comp1.getClass()); debug = false; } if (!onePropValue.equals(twoPropValue)) { ReasonNotEquals.addReason( "expect property values to be equal, got <" + onePropValue + "> and <" + twoPropValue + ">"); result = false; break; } else { // Err.pr( "\tconcordance, prop name " + onePropName + ", prop value " + // onePropValue); } } } } if (result == false) { break; // so break out of outer loop too } } } } } return result; }
/** * 处理单一的请求package * * @throws CloneNotSupportedException */ public com.sinosoft.ec.webservices.jd.pojo.hebaoResponse.Package DealPackage( com.sinosoft.ec.webservices.jd.pojo.hebaoRequest.Package rp) { com.sinosoft.ec.webservices.jd.pojo.hebaoResponse.Package rsp = new com.sinosoft.ec.webservices.jd.pojo.hebaoResponse.Package(); /** iCare自核保 */ /** 非空校验 */ Err err = new Err(); if (!checkNull(rp, err)) { u.buildHeBaoEmptyRSP(rp, rsp, err); return rsp; } /** 确认此产品是否在本接口中可卖 */ if (!isOnSale(rp.getHeader().getProductCode(), err)) { u.buildHeBaoEmptyRSP(rp, rsp, err); return rsp; } /** 数据有效性校验 */ String key = getiCareCheckModelKey(rp.getHeader().getProductCode()); ICareCheckModelInterface checkModel = new ICareCheckModelFactory().getICareCheckModelInterface(key); err.setErr(checkModel.check(rp)); checkModel = null; if (!dealiCareCheckResult(err)) { u.buildHeBaoEmptyRSP(rp, rsp, err); return rsp; } /** 保费校验 */ if (!CheckPrem(rp, rsp, err)) { return rsp; } /** 初始化各个数据库对象 */ MMap map = new MMap(); HashMap<String, Object> hmap = new HashMap<String, Object>(); if (!initDBSchema(rp, err, map, hmap)) { u.buildHeBaoEmptyRSP(rp, rsp, err); return rsp; } /** 调用MTS核保 */ if (!u.checkWithMTS(hmap, err)) { u.buildHeBaoEmptyRSP(rp, rsp, err); return rsp; } System.out.println("-=-=-=-=-=-=-=-=-=-=-="); /** 保存数据 */ if (!saveData(map)) { u.buildHeBaoEmptyRSP(rp, rsp, err); return rsp; } map = null; /** 建立返回Package对象并返回 */ u.buildHeBaoRSP(hmap, rp, rsp); hmap = null; return rsp; }
public Err tooFewArgs(int given) { return Err.make("Too few arguments: " + given + " < " + type.params.length); }
public void add(int index, Object o) { Err.pr("####### DEBUG add[@1]: <" + o + "> to " + id); // Err.stack(); super.add(index, o); }
public boolean remove(Object obj) { Err.pr("####### DEBUG rem: <" + obj + "> from " + id); return super.remove(obj); }
public void setOutBufferSize(TcpSocket fan, Long v) { if (in != null) throw Err.make("Must set outBufSize before connection"); outBufSize = (v == null) ? 0 : v.intValue(); }
public void clear() { Err.pr("####### DEBUG clear on " + id); super.clear(); }