List of usage examples for java.lang Class getField
@CallerSensitive public Field getField(String name) throws NoSuchFieldException, SecurityException
From source file:org.eclipse.emf.mwe.utils.StandaloneSetup.java
/** * Adds an extension//from w w w .j a v a 2 s . c o m * * @param m * <tt>from</tt>: extension name, <tt>to</tt> factory classname * @throws ConfigurationException * <ul> * <li>The factory class for the extension cannot be found * <li>The inner factory class for the extension cannot be found * </ul> */ public void addExtensionMap(final Mapping m) throws ConfigurationException { log.info("Adding Extension mapping from '" + m.getFrom() + "' to '" + m.getTo() + "'"); try { // locate the factory class of the extension Class<?> factoryClass = ResourceLoaderFactory.createResourceLoader().loadClass(m.getTo()); if (factoryClass == null) throw new ConfigurationException( "cannot find class " + m.getTo() + " for extension " + m.getFrom()); Object factoryInstance = null; if (factoryClass.isInterface()) { final Class<?>[] innerClasses = factoryClass.getDeclaredClasses(); factoryClass = null; for (int j = 0; j < innerClasses.length; j++) { if (Resource.Factory.class.isAssignableFrom(innerClasses[j])) { factoryClass = innerClasses[j]; } } if (factoryClass == null) throw new ConfigurationException( "cannot find inner factory class " + m.getTo() + " for extension " + m.getFrom()); final Field instanceField = factoryClass.getField("INSTANCE"); factoryInstance = instanceField.get(null); } else { factoryInstance = factoryClass.newInstance(); } Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put(m.getFrom(), factoryInstance); } catch (final Exception e) { throw new ConfigurationException(e); } }
From source file:com.liangxun.university.huanxin.chat.activity.ChatOldActivity.java
/** * ?gridview?view/*from w ww . jav a 2 s .co m*/ * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // ???? // ????? if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // ? // ????SmileUtils Class clz = Class.forName("SmileUtils"); Field field = clz.getField(filename); mEditTextContent.append( HxSmileUtils.getSmiledText(ChatOldActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// ?? if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// ??? if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (HxSmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }
From source file:niltor.net.chatuidemo.activity.ChatActivity.java
/** * ?gridview?view//from w w w . j a v a 2 s. c o m * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // ???? // ????? if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // ? // ????SmileUtils Class clz = Class.forName("niltor.net.chatuidemo.utils.SmileUtils"); Field field = clz.getField(filename); mEditTextContent .append(SmileUtils.getSmiledText(ChatActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// ?? if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// ??? if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (SmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }
From source file:org.jboss.dashboard.workspace.CopyManagerImpl.java
/** * Copy permissions define for a given resource and assigns created copies to another resource. * * @param resource The resource which permissions are going to be copied. * @param resourceCopy The resource that is going to receive the copied permissions. * @param permissionClass The copy is restricted to the given permission class. * @param targetWorkspace The workspace where copied resource will be stored. * @throws Exception//from w w w . j av a2s.com */ protected void copyPermissions(Object resource, Object resourceCopy, Class permissionClass, Workspace targetWorkspace) throws Exception { // First retrieve permissions (only permissionClass instances) assigned to resource. Policy securityPolicy = SecurityServices.lookup().getSecurityPolicy(); Map permissionMap = securityPolicy.getPermissions(resource, permissionClass); // Start permissions and principals copy. Iterator permIt = permissionMap.keySet().iterator(); while (permIt.hasNext()) { Principal principal = (Principal) permIt.next(); // Copy permission DefaultPermission permission = (DefaultPermission) permissionMap.get(principal); Method getInstance = permissionClass.getMethod("getInstance", new Class[] { Principal.class, Object.class }); DefaultPermission permissionCopy = (DefaultPermission) getInstance.invoke(permissionClass, new Object[] { principal, resourceCopy }); List actionList = (List) permissionClass.getField("LIST_OF_ACTIONS").get(permissionClass); for (int k = 0; k < actionList.size(); k++) { String action = (String) actionList.get(k); if (permission.isActionDenied(action)) permissionCopy.denyAction(action); else if (permission.isActionGranted(action)) permissionCopy.grantAction(action); else if (permission.isActionUndefined(action)) permissionCopy.removeAction(action); } // Add permission to security policy if values for it have been specified. if (!permissionCopy.isEmpty()) { securityPolicy.addPermission(principal, permissionCopy); log.debug("Set permission for cloned workspace " + principal.getName() + " " + permissionCopy.toString()); } // If permission is empty then ensure that is not registered into the security policy else { securityPolicy.removePermission(principal, permissionCopy); log.debug("Set permission for cloned workspace: " + principal.getName() + " " + permissionCopy.toString()); } } // Make policy changes persistent securityPolicy.save(); }
From source file:la.zmkm.agent.activity.ChatOldActivity.java
/** * ?gridview?view/* w ww . j a v a2 s. co m*/ * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // ???? // ????? if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // ? // ????SmileUtils Class clz = Class.forName("SmileUtils"); Field field = clz.getField(filename); mEditTextContent.append( SmileUtils.getSmiledText(ChatOldActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// ?? if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// ??? if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (SmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }
From source file:com.interestfriend.activity.FeedBackActivity.java
/** * gridviewview//from w w w .j av a 2s . co m * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // // if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // // SmileUtils Class clz = Class.forName("com.interestfriend.utils.SmileUtils"); Field field = clz.getField(filename); mEditTextContent.append( SmileUtils.getSmiledText(FeedBackActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (SmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }
From source file:com.imalu.alyou.activity.ChatOldActivity.java
/** * ?gridview?view//from www . jav a 2s .c o m * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // ???? // ????? if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // ? // ????SmileUtils Class clz = Class.forName("com.imalu.alyou.utils.SmileUtils"); Field field = clz.getField(filename); mEditTextContent.append( SmileUtils.getSmiledText(ChatOldActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// ?? if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// ??? if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (SmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }
From source file:com.zhixu.icu.activity.ChatActivity.java
/** * ?gridview?view//from ww w. j av a 2s .com * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // ???? // ????? if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // ? // ????SmileUtils Class clz = Class.forName("com.zhixu.icu.utils.SmileUtils"); Field field = clz.getField(filename); mEditTextContent .append(SmileUtils.getSmiledText(ChatActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// ?? if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// ??? if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (SmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }
From source file:com.safeness.im.activity.ChatOldActivity.java
/** * ?gridview?view//from w ww .j a v a 2 s . c o m * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // ???? // ????? if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // ? // ????SmileUtils Class clz = Class.forName("com.safeness.im.utils.SmileUtils"); Field field = clz.getField(filename); mEditTextContent.append( SmileUtils.getSmiledText(ChatOldActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// ?? if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// ??? if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (SmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }
From source file:cn.kangeqiu.kq.activity.ChatOldActivity.java
/** * ?gridview?view//from ww w.j a v a 2 s .c o m * * @param i * @return */ private View getGridChildView(int i) { View view = View.inflate(this, R.layout.expression_gridview, null); ExpandGridView gv = (ExpandGridView) view.findViewById(R.id.gridview); List<String> list = new ArrayList<String>(); if (i == 1) { List<String> list1 = reslist.subList(0, 20); list.addAll(list1); } else if (i == 2) { list.addAll(reslist.subList(20, reslist.size())); } list.add("delete_expression"); final ExpressionAdapter expressionAdapter = new ExpressionAdapter(this, 1, list); gv.setAdapter(expressionAdapter); gv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { String filename = expressionAdapter.getItem(position); try { // ???? // ????? if (buttonSetModeKeyboard.getVisibility() != View.VISIBLE) { if (filename != "delete_expression") { // ? // ????SmileUtils Class clz = Class.forName("com.easemob.chatuidemo.utils.SmileUtils"); Field field = clz.getField(filename); mEditTextContent.append( SmileUtils.getSmiledText(ChatOldActivity.this, (String) field.get(null))); } else { // if (!TextUtils.isEmpty(mEditTextContent.getText())) { int selectionStart = mEditTextContent.getSelectionStart();// ?? if (selectionStart > 0) { String body = mEditTextContent.getText().toString(); String tempStr = body.substring(0, selectionStart); int i = tempStr.lastIndexOf("[");// ??? if (i != -1) { CharSequence cs = tempStr.substring(i, selectionStart); if (SmileUtils.containsKey(cs.toString())) mEditTextContent.getEditableText().delete(i, selectionStart); else mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } else { mEditTextContent.getEditableText().delete(selectionStart - 1, selectionStart); } } } } } } catch (Exception e) { } } }); return view; }