Java Code Examples for org.hy.common.Help#isNull()
The following examples show how to use
org.hy.common.Help#isNull() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AppParameter.java From hy.common.base with Apache License 2.0 | 6 votes |
/** * 是否显示帮助信息 * * @return */ public boolean isShowVersion() { if ( Help.isNull(this.parameters) ) { return false; } if ( this.parameters.containsKey("/version") ) { return true; } else if ( this.parameters.containsKey("/v") ) { return true; } else { return false; } }
Example 2
Source File: Jobs.java From hy.common.tpool with Apache License 2.0 | 6 votes |
/** * 是否启动的灾备机制 * * @author ZhengWei(HY) * @createDate 2019-02-21 * @version v1.0 * * @return */ public boolean isDisasterRecovery() { if ( Help.isNull(this.disasterRecoverys) ) { return false; } else if ( this.disasterRecoverys.size() >= 2 ) { return true; } else { return false; } }
Example 3
Source File: RTemplate.java From hy.common.report with Apache License 2.0 | 6 votes |
@Override public int hashCode() { int v_Ret = 0; if ( !Help.isNull(this.name) ) { v_Ret = this.name.hashCode(); } if ( !Help.isNull(this.excelFileName) ) { v_Ret += this.excelFileName.hashCode() * 1000; } if ( v_Ret == 0 ) { return super.hashCode(); } return v_Ret; }
Example 4
Source File: RTemplate.java From hy.common.report with Apache License 2.0 | 6 votes |
@Override public int compareTo(RTemplate i_Other) { if ( i_Other == null ) { return 1; } else if ( this == i_Other ) { return 0; } else { if ( Help.isNull(this.name) || Help.isNull(this.excelFileName) ) { return -1; } int v_Ret = this.name.compareTo(i_Other.getName()); if ( v_Ret == 0 ) { v_Ret = this.excelFileName.compareTo(i_Other.getExcelFileName()); } return v_Ret; } }
Example 5
Source File: RTemplate.java From hy.common.report with Apache License 2.0 | 5 votes |
@Override public boolean equals(Object i_Other) { if ( this == i_Other ) { return true; } else if ( i_Other == null ) { return false; } else if ( i_Other instanceof RTemplate ) { boolean v_Ret = false; if ( !Help.isNull(this.name) ) { v_Ret = this.name.equals(((RTemplate)i_Other).getName()); } if ( !v_Ret ) { return false; } if ( !Help.isNull(this.excelFileName) ) { v_Ret = this.excelFileName.equals(((RTemplate)i_Other).getExcelFileName()); } return v_Ret; } else { return false; } }
Example 6
Source File: MenuExportStructureAction.java From HBaseClient with GNU General Public License v3.0 | 5 votes |
@Override public void onClick(ActionEvent arg0) { List<String> v_TableNames = this.getHBase().getTableNames(); if ( Help.isNull(v_TableNames) ) { this.getAppFrame().showHintInfo("数据库中不存在表" ,Color.BLUE); return; } if ( this.fileChooser == null ) { this.fileChooser = new JFileChooser(); } File v_SaveFile = new File(this.getHBase().getHBaseIP() + ".txt"); this.fileChooser.setSelectedFile(v_SaveFile); try { // 不知道为什么非要sleep一下才再在多次反复打开对话窗口时不出异常,保证每次都能打开对话窗口。 // 测试环境:Mac 10.12.5、Java 1.6、Eclipse 4.3.2 Thread.sleep(10); } catch (Exception exce) { // Nothing. } int v_Result = this.fileChooser.showSaveDialog(this.getAppFrame()); if ( v_Result == JFileChooser.APPROVE_OPTION ) { v_SaveFile = this.fileChooser.getSelectedFile(); this.writeContents(v_TableNames ,v_SaveFile); } }
Example 7
Source File: AppMain.java From HBaseClient with GNU General Public License v3.0 | 5 votes |
private static void executes(File i_File ,String i_FileType) { String v_FileType = i_FileType; if ( Help.isNull(v_FileType) ) { v_FileType = getFileType(i_File); } if ( i_File.isFile() ) { if ( !i_File.exists() ) { System.out.println("File [" + i_File.getAbsolutePath() + "] is not exists."); } if ( !i_File.canRead() ) { System.out.println("File [" + i_File.getAbsolutePath() + "] can not read."); } try { executes($FileHelp.getContent(i_File ,Help.NVL(v_FileType ,"UTF-8") ,true)); } catch (Exception exce) { System.out.println("File [" + i_File.getAbsolutePath() + "] error:" + exce.getMessage()); } } }
Example 8
Source File: ExcelFormula.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 将Excel单元格ID,转换为Java语言标识的行号、列号。 * * 如,将A1翻译为,第1列第1行,实际返回 0,0 ,下标均从0开始 * * @author ZhengWei(HY) * @createDate 2020-05-19 * @version v1.0 * * @param i_CellExcelID Excel单元格ID,如1 * @return */ public static RCell cellIDtoJava(String i_CellExcelID) { if ( Help.isNull(i_CellExcelID) ) { return null; } String [] v_CEIDArr = i_CellExcelID.split("!"); String v_CEID = v_CEIDArr[v_CEIDArr.length - 1]; String v_CellExcelID = StringHelp.replaceAll(v_CEID.trim().toUpperCase() ,"$" ,""); String v_RowName = StringHelp.replaceAll(v_CellExcelID ,$A_TO_Z ,new String [] {""}); if ( Help.isNull(v_RowName) || !Help.isNumber(v_RowName) || StringHelp.isContains(v_RowName ,"." ,"-" ," ") ) { return null; } int v_RowNo = Integer.parseInt(v_RowName); String v_ColName = StringHelp.replaceAll(v_CellExcelID ,v_RowNo + "" ,""); if ( v_ColName.length() <= 0 || v_ColName.length() > 3 ) { return null; } RCell v_Ret = new RCell(); v_Ret.setRowNo( v_RowNo - 1); v_Ret.setColNo(StringHelp.reABC26(v_ColName)); v_Ret.setFixedRow(v_CEID.trim().indexOf("$") > 0); v_Ret.setFixedCol(v_CEID.trim().startsWith("$")); return v_Ret; }
Example 9
Source File: RTemplate.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * Excel转Java时,将Excel单位格中的数据映射并赋值给Java对象的属性 * * @author ZhengWei(HY) * @createDate 2017-05-09 * @version v1.0 * * @param i_ValueName 占位符名称 * @param i_Value Excel单位格中的数据 * @param io_RowObj Java对象 * @return 映射赋值成功时返回true */ public boolean setValue(String i_ValueName ,Object i_Value ,Object io_RowObj) { if ( Help.isNull(i_ValueName) ) { return false; } RCellGroup v_RCellG = this.valueMethods.get(i_ValueName); if ( v_RCellG == null ) { return false; } RCell v_RCell = v_RCellG.get(0); if ( null != v_RCell && null != v_RCell.getValueSetMethod() ) { try { v_RCell.getValueSetMethod().invokeSetForInstance(io_RowObj ,i_Value); return true; } catch (Exception exce) { exce.printStackTrace(); } } return false; }
Example 10
Source File: ExcelHelp.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 创建一个工作表 * * @author ZhengWei(HY) * @createDate 2017-03-16 * @version v1.0 * * @param i_Workbook 工作薄对象 * @param i_SheetName 工作表名称(当为空时,自动生成) * @return */ public final static Sheet createSheet(Workbook i_Workbook ,String i_SheetName) { int v_SheetCount = i_Workbook.getNumberOfSheets(); String v_SheetName = i_SheetName; if ( Help.isNull(v_SheetName) ) { v_SheetName = "sheet" + (v_SheetCount + 1); } return i_Workbook.createSheet(v_SheetName); }
Example 11
Source File: RTemplate.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 添加自定义变量处理事件的监听者 * * @author ZhengWei(HY) * @createDate 2017-03-18 * @version v1.0 * * @param i_Listener */ public void addListener(ValueListener i_Listener) { if ( i_Listener == null ) { throw new NullPointerException("ValueListener is null."); } if ( Help.isNull(i_Listener.getValueName()) ) { throw new NullPointerException("ValueListener.getValueName() is null."); } this.valueListeners.put(this.getValueSign() + i_Listener.getValueName() ,i_Listener); }
Example 12
Source File: ClassReflect.java From hy.common.base with Apache License 2.0 | 5 votes |
/** * 从指定集合i_Classes中,挑出有注解的Class。并分类存储。 * * @param i_Classes Java元类型的集合 * @param i_AnnotationClass 注解类型的元类型 * @return */ public static PartitionMap<ElementType ,ClassInfo> getAnnotations(List<Class<?>> i_Classes ,Class<? extends Annotation> i_AnnotationClass) { PartitionMap<ElementType ,ClassInfo> v_Ret = new TablePartition<ElementType ,ClassInfo>(); for (int i=0; i<i_Classes.size(); i++) { Class<?> v_Class = i_Classes.get(i); ClassInfo v_ClassInfo = new ClassInfo(v_Class); // 为了在多个分区引用同一对象,所以在此无论是否被注解都new // 判断类是否注解 if ( v_Class.isAnnotationPresent(i_AnnotationClass) ) { v_Ret.putRow(ElementType.TYPE ,v_ClassInfo); } // 判断类中的自有方法是否注解 List<Method> v_Methods = MethodReflect.getAnnotationMethods(v_Class ,i_AnnotationClass); if ( !Help.isNull(v_Methods) ) { v_ClassInfo.setMethods(v_Methods); v_Ret.putRow(ElementType.METHOD ,v_ClassInfo); } // 判断类中的自有属性是否注解 List<Field> v_Fields = getAnnotationFields(v_Class ,i_AnnotationClass); if ( !Help.isNull(v_Fields) ) { v_ClassInfo.setFields(v_Fields); v_Ret.putRow(ElementType.FIELD ,v_ClassInfo); } } return v_Ret; }
Example 13
Source File: ExcelFormula.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 计算单元格在偏移量(偏移多少行、偏移多少列)后新的单元格ID * * 如,A1偏移1行为:A2 * 如,A1偏移1列为:B1 * * @author ZhengWei(HY) * @createDate 2020-05-20 * @version v1.0 * * @param i_CellExcelID 单元格的ID。为Excel与人交互的ID,如,A1表示第1列的第1行坐标位置上单元格。 * @param i_OffsetRow 偏移多少行。零值,表示不偏移;负值向i_CellExcelID上方偏移;正值向i_CellExcelID下方偏移。 * @param i_OffsetCol 偏移多少列。零值,表示不偏移;负值向i_CellExcelID左方偏移;正值向i_CellExcelID右方偏移。 * @return */ public static String calcCellOffset(String i_CellExcelID ,int i_OffsetRow ,int i_OffsetCol) { if ( Help.isNull(i_CellExcelID) ) { return i_CellExcelID; } if ( StringHelp.getCount(i_CellExcelID ,"\\$") >= 2 ) { // 绝对行、绝对列是不能偏移的。 return i_CellExcelID; } RCell v_RCell = cellIDtoJava(i_CellExcelID); if ( v_RCell == null ) { return i_CellExcelID; } if ( !v_RCell.isFixedRow() ) { v_RCell.setRowNo(Help.max(v_RCell.getRowNo() + i_OffsetRow ,0)); } if ( !v_RCell.isFixedCol() ) { v_RCell.setColNo(Help.max(v_RCell.getColNo() + i_OffsetCol ,0)); } return cellIDtoExcel(v_RCell); }
Example 14
Source File: RTemplate.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 获取报表模板对应的工作表 * * @author ZhengWei(HY) * @createDate 2017-03-16 * @version v1.0 * * @return */ public synchronized Sheet getTemplateSheet() { if ( null == this.templateSheet ) { this.isCheck = true; List<Sheet> v_Sheets = ExcelHelp.read(this.excelFileName); if ( Help.isNull(v_Sheets) ) { this.templateSheet = null; } else { this.templateSheet = v_Sheets.get(this.sheetIndex); } this.init(); this.getExcelVersion(); if ( this.getTitlePageHeaderFirstWriteByRow() >= 1 ) { this.titlePageHeaderFirstWriteByRealDataCount = this.getTitlePageHeaderFirstWriteByRow() - this.getRowCountTitlePageFooter() - this.getRowCountTitle(); this.titlePageHeaderRate = this.getRowCountTitlePageHeader(); } else { this.titlePageHeaderFirstWriteByRealDataCount = 0; this.titlePageHeaderRate = 0; } } return this.templateSheet; }
Example 15
Source File: ExcelFormula.java From hy.common.report with Apache License 2.0 | 5 votes |
/** * 解释公式,将公式中的单元格ID独立提取出来。 * * 1. 会去除重复的单元格ID * 2. 会去除绝对行、绝对列定位的单元格ID * 3. 保留只绝对行 或 只绝对列定位的单格ID,去除绝对行及绝对列的单元格ID * * @author ZhengWei(HY) * @createDate 2020-05-20 * @version v1.0 * * @param i_Formula Excle公式 * @return */ public static String [] parserFormula(String i_Formula) { if ( Help.isNull(i_Formula) ) { return new String[0]; } String v_CellIDs = ""; v_CellIDs = StringHelp.trim(i_Formula.trim().toUpperCase()); v_CellIDs = StringHelp.replaceAll(v_CellIDs ,$Formulas ,new String[] {$ParserFormulaSplit}); v_CellIDs = StringHelp.trimToDistinct(v_CellIDs ,$ParserFormulaSplit); String [] v_CellIDArr = v_CellIDs.split($ParserFormulaSplit); if ( Help.isNull(v_CellIDArr) ) { return new String[0]; } List<String> v_CellIDList = Help.toDistinct(v_CellIDArr); for (int i=v_CellIDList.size()-1; i>=0; i--) { if ( Help.isNull(v_CellIDList.get(i)) ) { // 去除空 v_CellIDList.remove(i); } else if ( StringHelp.getCount(v_CellIDList.get(i) ,"\\$") >= 2 ) { // 去除绝对行、绝对列定位的单元格ID v_CellIDList.remove(i); } } if ( Help.isNull(v_CellIDList) ) { return new String[0]; } return v_CellIDList.toArray(new String[] {}); }
Example 16
Source File: TaskTypeTotal.java From hy.common.tpool with Apache License 2.0 | 5 votes |
/** * 活动的任务类型数++ * * @param i_TaskType */ public void active(String i_TaskType) { if ( Help.isNull(i_TaskType) ) { throw new NullPointerException("Task Type is null"); } this.taskTypeTotalChange(i_TaskType, 1); }
Example 17
Source File: Job.java From hy.common.tpool with Apache License 2.0 | 4 votes |
/** * 执行任务的方法 */ public void execute() { if ( Help.isNull(this.xid) ) { throw new NullPointerException("Job.getXid() is null."); } if ( Help.isNull(this.methodName) ) { throw new NullPointerException("Job.getMethodName() is null."); } try { Date v_Now = new Date(); boolean v_IsAllow = false; if ( this.lastTime == null ) { v_IsAllow = true; this.lastTime = v_Now; } else if ( this.intervalType == Job.$IntervalType_Second || this.intervalType == Job.$IntervalType_Manual || this.jobs == null) { v_IsAllow = true; this.lastTime = v_Now; } // 第二个地方再次预防,第一个地方在Jobs.execute()中。 // 又添加一次预防的原因是:这里离 this.lastTime = new Date(); 最近。 // 预防因主机系统时间不精确,时间同步机制异常(如来回调整时间、时间跳跃、时间波动等), // 造成定时任务重复执行的可能。 ZhengWei(HY) Add 2019-03-06 else if ( !this.getLastTime().equalsYMDHM(v_Now) && this.getLastTime().differ(v_Now) < 0 ) { v_IsAllow = true; this.lastTime = v_Now; } // 手工执行时 else if ( this.jobs != null && !this.jobs.isMonitor(this) ) { v_IsAllow = true; this.lastTime = v_Now; } if ( v_IsAllow ) { this.runCount++; this.runLogs.put(this.lastTime.getFullMilli()); // 本机执行:默认的 if ( this.cloudSocket == null ) { Object v_Object = XJava.getObject(this.xid.trim()); if ( v_Object == null ) { throw new NullPointerException("Job.getXid() = " + this.xid + " XJava.getObject(...) is null."); } (new Execute(v_Object ,this.methodName.trim())).start(); } // 云服务执行:当配置CloudServer时。 else { (new Execute(this.cloudSocket ,"sendCommand" ,new Object[]{this.xid ,this.methodName.trim() ,false})).start(); } System.out.println(Date.getNowTime().getFullMilli() + " 执行定时任务 " + this.xid + ":" + this.getTaskDesc()); } } catch (Exception exce) { exce.printStackTrace(); } if ( this.jobs != null ) { // 注意:delMonitor()方法不要加同步锁。否则会出现线程阻塞 this.jobs.delMonitor(this); this.finishTask(); } else { // 当 this.jobs 为空时,表示本方法是手工执行,并不是定时任务自动执行的。 } }
Example 18
Source File: AppFrame.java From HBaseClient with GNU General Public License v3.0 | 4 votes |
/** * 设置当前选择的表对象 * * 将触发以下多个动作: * 1. 获取列族信息 (设置查询条件及编辑面板中的列族名控件) * 2. 猜想表结构 (设置查询条件及编辑面板中的字段名控件) * 3. 全表查询动作 * * @param tableName */ public synchronized void setTableName(String i_TableName) { this.tableName = i_TableName; if ( Help.isNull(this.tableName) ) { return; } this.getHPage().setRowKey(""); this.setTables_Tools_Edit_Enabled(true); ((JTextComponent)XJava.getObject("RowKey")) .setText(""); ((JTextComponent)XJava.getObject("ColumnValue")).setText(""); ((JCheckBox) XJava.getObject("IsLike")) .setSelected(true); // 获取列族信息 JComboBox v_FamilyNameObj = (JComboBox)XJava.getObject("FamilyName"); JComboBox v_FamilyEditObj = (JComboBox)XJava.getObject("Edit_FamilyName"); v_FamilyNameObj.removeAllItems(); v_FamilyEditObj.removeAllItems(); v_FamilyNameObj.addItem("" ,""); v_FamilyEditObj.addItem("" ,""); List<String> v_FamilyNames = this.hbase.getTableFamilyNames(this.tableName); for (String v_FamilyName : v_FamilyNames) { v_FamilyNameObj.addItem(v_FamilyName ,v_FamilyName); v_FamilyEditObj.addItem(v_FamilyName ,v_FamilyName); } // 猜想表结构 this.structure = this.hbase.getTableStructure(this.tableName); this.initColumnNames("" ,(JComboBox)XJava.getObject("ColumnName")); this.initColumnNames("" ,(JComboBox)XJava.getObject("Edit_ColumnName")); // 全表查询动作 ((JButton)XJava.getObject("xbSubmit")).doClick(); }
Example 19
Source File: AppMain.java From HBaseClient with GNU General Public License v3.0 | 4 votes |
public static void main(String[] i_Args) throws Exception { AppParameter v_Apps = new AppParameter(i_Args); String v_HBaseIP = v_Apps.getParamValue("ip"); String v_FileName = v_Apps.getParamValue("file"); String v_FileType = v_Apps.getParamValue("fileType"); String v_CMD = v_Apps.getParamValue("cmd"); String v_Language = Help.NVL(v_Apps.getParamValue("language") ,"cn"); if ( v_Apps.isShowVersion() ) { System.out.println(showVersionInfo()); return; } if ( v_Apps.isShowHelp() ) { System.out.println(showHelpInfo()); return; } if ( Help.isNull(v_HBaseIP) ) { System.out.println("Parameter [ip] is null."); return; } $HBase = new HBase(v_HBaseIP); $HBase.setResultType(ResultType.ResultType_HData); if ( v_Apps.isExists("-window") ) { XJava.putObject("SYS_LANGUAGE" ,v_Language); XJava.parserAnnotation("org.hy.hbase"); AppFrame v_AppFrame = (AppFrame)XJava.getObject("AppFrame"); Dimension v_Dimension = Toolkit.getDefaultToolkit().getScreenSize(); v_Dimension.height = v_Dimension.height - 40; v_AppFrame.setHBase($HBase); v_AppFrame.setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(v_AppFrame.getClass().getResource("img/HBase.png"))); v_AppFrame.setSize(v_Dimension); v_AppFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); v_AppFrame.setTitle("HBase客户端 " + $VersionNo); v_AppFrame.setVisible(true); v_AppFrame.validate(); v_AppFrame.init(); return; } if ( Help.isNull(v_CMD) ) { if ( Help.isNull(v_FileName) ) { System.out.println("Parameter [file] is null."); return; } exeutesFile(new File(v_FileName) ,v_FileType); } else { executes(v_CMD); } }
Example 20
Source File: RTemplate.java From hy.common.report with Apache License 2.0 | 3 votes |
/** * 添加自动行高的变量名称 * * @author ZhengWei(HY) * @createDate 2017-09-11 * @version v1.0 * * @param i_ValueName 变量名称 */ public void setAddAutoHeight(String i_ValueName) { if ( !Help.isNull(i_ValueName) ) { this.autoHeights.put(this.valueSign + i_ValueName ,i_ValueName); } }