salesforce 大概分成两个部分:Apex,VisualForce Page
其中Apex 语法和java 语法很相似其中:
常用的基本变量有:种常用的基本变量Integer,String,Decimal,Double,Long,Boolean,ID。
常用的集合对象:List,Set,Map
其他:Object 和 sObject
其中sObject 定义为:Salesforce中的标准对象或自定义对象在Apex中使用时被称作“sObject”。sObject对象的一个实例相当于Salesforce中的一条记录。
一、基本变量
- Integer
主要方法: public String format() // Integer转String public static Integer valueOf(String stringToObject) //String转Integer
- Long
主要方法: public String format() //转String public Integer intValue() //转Integer public static Long valueOf(String stringToLong) //String 转Long
- Decimal
主要方法: public Decimal abs() //返回小数点的绝对值 public Decimal divide(Decimal divisor, Integer scale) // 除数为divisor 返回结果为scale位数 public Double doubleValue() // 转double public String format() // 转string public Integer intValue() //转Integr public Long longValue() public Integer precision() //返回 值对应的数字个数 如 3.2 返回为2 即3和2 public Long round() //转换Long 四舍五入 public Integer scale() //返回小数点后的位数个数 public Decimal setScale(Integer scale) //设置小数点后的位数个数 public Decimal stripTrailingZeros() // 去除0以后的小数 Decimal.valueOf(Object objectToDecimal)// 将Double Long String 等转换成Decimal
- Boolean
需注意的一点 默认为null - Double
主要方法: public static Double valueOf(String stringToDouble) public Long round() // 四舍五入返回Long public Integer intValue() //转 Integer
- ID
ID类型可以用任何一个符合规则的18位字符表示,如果你设置ID字符为15位,则将字符自动扩展成18位。不符合规则的ID字符在运行时则运行时异常主要方法: public static ID valueOf(String toID) //将toId转换成ID public Boolean equals(String id) //判断两个ID是否相同
- String
主要方法: //返回简化字符串,maxWidth>自身长度?自身:maxWidth长度的字符串加上省略号,省略号占3个字符 public String abbreviate(Integer maxWidth) //注意:maxWidth如果小于4,则抛出Runtime Exception public String abbreviate(Integer maxWidth,Integer offset) //返回简化字符串,maxWidth为需要简化长度,offset为字符串简化起点 //如果max太小,则抛出Runtime Exception public String capitalize() //返回当前字符串,其中第一个字母改为标题(大写)。 public String center(Integer size) //返回指定大小字符串使原字符串位于中间位置(空格填充左右),如果size<字符串长度,则不起作用 public String center(Integer size,String paddingString) //返回指定大小字符串使原字符串处于中间位置。参数1:字符串显示长度;参数2:填充的字符样式 public Integer charAt(Integer index) //返回对应值得ASC码值 public Integer codePointAt(Integer index) //返回指定位置的值对应的Unicode编码 public Integer codePointBefore(Integer index) //返回指定位置的值前一个对应的Unicode编码 public Integer codePointCount(Integer beginIndex,Integer endIndex) //返回起始位置到截至位置字符串的Unicode编码值 public Integer compareTo(String secondString) //基于Unicode比较两个字符串大小,如果小于比较值返回负整数,大于返回正整数,等于返回0 public Boolean contains(String substring) //判断是否包含某个字符串,包含返回true,不包含返回false public Boolean containsAny(String inputString) //判断是否包含inputString任意一个字符,包含返回true,不包含返回false public Boolean containsIgnoreCase(String inputString) //判断是否包含inputString(不区分大小写),包含返回true,不包含返回false public Boolean containsNone(String inputString) //判断是否不包含inputString,不包含返回true,包含返回false public Boolean containsOnly(String inputString) //当前字符串从指定序列只包括inputString返回true,否则返回false public Boolean containsWhitespace() //判断字符串是否包含空格,包含返回true,不包含返回false public Integer countMatches(String substring) //判断子字符串在字符串中出现的次数 public String deleteWhitespace() 移除字符串中所有的空格 //返回两个字符串之间不同,如果anotherString为空字符串,则返回空字符串,如果anotherString为null,则抛异常 比较结果以anotherString为基准,从第一个字符比较,不相同则返回anotherString与源字符串不同之处 public Boolean endsWith(String substring) //判断字符串是否已substring截止,如果是返回true,否则返回false public Boolean endsWithIgnoreCase(String substring) //判断字符串是否已subst