68、Schema的相关类
public class SObjectSchema { public void testSchema(){
//获取SObject的token
//1、先获取所有token,然后通过key获取需要的token
//2、直接获取指定的sObject的token //1、通过获取全部描述信息,然后get方法获取需要的指定字段的描述信息
Map<String,Schema.SObjectType> allSObjectTypeDescribes = Schema.getGlobalDescribe();
Schema.SObjectType merchandiseType1 = allSObjectTypeDescribes.get('Merchandise__c'); //2、直接获取指定sObject的token
Schema.SObjectType merchandiseType2 = Merchandise__c.SObjectType; /*
* 获取Schema.DescribeSObjectResult
* 1、通过token的getDescribe方法**/
Schema.DescribeSObjectResult merchandiseResult = merchandiseType1.getDescribe(); /*
* 2、通过System命名空间下的Schema的方法
* */
List<String> sObjectTypes = new String[]{'Merchandise__c'};
List<Schema.DescribeSObjectResult> merchandiseResult1 = Schema.describeSObjects(sObjectTypes);
System.debug(merchandiseResult.getLabel());
System.debug('sObject的API的名称为' + merchandiseResult.getName());
System.debug('Student表是否为自定义的Object :' + (merchandiseResult.isCustom() ? '是':'否'));
//---------------------------------------//
List<Schema.ChildRelationship> childRelationResult = merchandiseResult.getChildRelationships();
for(Schema.ChildRelationship child : childRelationResult){
System.debug('merchandise子Object的关联名称:'+ child.getRelationshipName());
}
/**
* 以下操作位获取field的元信息结果,以Education__c为例
* 两种操作方式:
* 1、通过DescribeSObjectResult的fields方法获取token,然后再通过getDescribe方法获取
* 2、直接获取字段然后使用getDescribe方法
* */
Map<String,SObjectField> sObjectFieldMaps = merchandiseResult.fields.getMap();
SObjectField educationField = sObjectFieldMaps.get('Merchandise__c');
Schema.DescribeFieldResult educationFieldResult = educationField.getDescribe();
Schema.DisplayType educationType = educationFieldResult.getType();
System.debug('education字段类型为:'+educationType);
System.debug('education字段API名称为:'+educationFieldResult.getName());
System.debug('education字段label名称为:'+educationFieldResult.getLabel());
//------------------------------//
List<Schema.PicklistEntry> educationListValues = educationFieldResult.getPicklistValues();
Map<String,Object> educationListValueMap = new Map<String,Object>();
/* for(Schema.PicklistEntry educationListItem : educationListValues){
educationListValueMap.put(educationListItem.getValue(),new Map<String,Object>{
'value'=>educationListItem.getValue(),
})
}*/
}
}
68、Schema的相关类的更多相关文章
- Android随笔之——Android时间、日期相关类和方法
今天要讲的是Android里关于时间.日期相关类和方法.在Android中,跟时间.日期有关的类主要有Time.Calendar.Date三个类.而与日期格式化输出有关的DateFormat和Simp ...
- 21 BasicTaskScheduler基本任务调度器(一)——Live555源码阅读(一)任务调度相关类
21_BasicTaskScheduler基本任务调度器(一)——Live555源码阅读(一)任务调度相关类 BasicTaskScheduler基本任务调度器 BasicTaskScheduler基 ...
- 8 延时队列相关类——Live555源码阅读(一)基本组件类
这是Live555源码阅读的第一部分,包括了时间类,延时队列类,处理程序描述类,哈希表类这四个大类. 本文由乌合之众 lym瞎编,欢迎转载 http://www.cnblogs.com/oloroso ...
- 4 Handler相关类——Live555源码阅读(一)基本组件类
这是Live555源码阅读的第一部分,包括了时间类,延时队列类,处理程序描述类,哈希表类这四个大类. Handler相关类概述 处理程序相关类一共有三个,其没有派生继承关系,但是其有友元关系和使用关系 ...
- MFC编程入门之十三(对话框:属性页对话框及相关类的介绍)
前面讲了模态对话框和非模态对话框,本节来将一种特殊的对话框--属性页对话框. 属性页对话框的分类 属性页对话框想必大家并不陌生,XP系统中桌面右键点属性,弹出的就是属性页对话框,它通过标签切换各个页面 ...
- android 6.0 SDK中删除HttpClient的相关类的解决方法
一.出现的情况 在eclipse或 android studio开发, 设置android SDK的编译版本为23时,且使用了httpClient相关类的库项目:如android-async-http ...
- Android 6.0删除Apache HttpClient相关类的解决方法
相应的官方文档如下: 上面文档的大致意思是,在Android 6.0(API 23)中,Google已经移除了Apache HttpClient相关的类,推荐使用HttpUrlConnection. ...
- List 接口以及实现类和相关类源码分析
List 接口以及实现类和相关类源码分析 List接口分析 接口描述 用户可以对列表进行随机的读取(get),插入(add),删除(remove),修改(set),也可批量增加(addAll),删除( ...
- Web---演示Servlet的相关类、表单多参数接收、文件上传简单入门
说明: Servlet的其他相关类: ServletConfig – 代表Servlet的初始化配置参数. ServletContext – 代表整个Web项目. ServletRequest – 代 ...
随机推荐
- php面试专题---1、php中变量存储及引用的原理
php面试专题---1.php中变量存储及引用的原理 一.总结 一句话总结: 查看变量的存储结构可以安装xdebug扩展,用xdebug_debug_zval()方法,不推荐使用memory_get_ ...
- 2.2寸(14PIN)TFT液晶屏STM32 SPI 控制
屏幕如图所示,共14个IO口(也可能只有13个),控制屏幕的有9个IO口 详细版介绍见:http://www.ciast.net/post/20151112.html 反面IO口图: 连接通过SPI方 ...
- xml解析用正则解决没有标签的文本的解析不出异常
如 <q>sasas<w>eqwe</w>ddas</q> package com.people.xmlToSql; import java.io.F ...
- git push github 免输入账号和密码方法
git config --global credential.helper store 打开~/.gitconfig文件,会发现多了一项: [credential] helper = store 此时 ...
- intellij中maven不能导入pom文件中指定的jar包
pom文件配置依赖的jar包版本,可以有默认的版本,如下 <profiles> <profile> <id>default_version</id> & ...
- 后端数据推送-EventSource
服务器发送事件(以下简称SSE)是HTML 5规范的一个组成部分,可以实现服务器到客户端的单向数据通信.通过SSE,客户端可以自动获取数据更新,而不用重复发送HTTP请求.一旦连接建立,“事件”便会自 ...
- UVALive 4992 Jungle Outpost(半平面交判存)
Jungle Outpost Time limit: 15.000 seconds Description There is a military base lost deep in the jung ...
- elementUI table宽度自适应fit
:fit='true' 或者直接为 fit
- 【摘】Linux虚拟地址空间布局以及进程栈和线程栈总结
在CSDN上看到的一篇文章,讲的还是满好的. 原文地址:Linux虚拟地址空间布局以及进程栈和线程栈总结 一:Linux虚拟地址空间布局 (转自:Linux虚拟地址空间布局) 在多任务操作系统中,每个 ...
- Nginx 常用基础模块
目录 Nginx 常用基础模块 Nginx日志管理 nginx日志切割 Nginx目录索引 Nginx状态监控 Nginx访问控制 Nginx访问限制 Nginx 请求限制配置实战 Nginx Loc ...