开源零听小清新范儿十足的音乐播放器代码案例.docx

上传人:b****3 文档编号:6605004 上传时间:2023-05-10 格式:DOCX 页数:27 大小:20.84KB
下载 相关 举报
开源零听小清新范儿十足的音乐播放器代码案例.docx_第1页
第1页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第2页
第2页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第3页
第3页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第4页
第4页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第5页
第5页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第6页
第6页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第7页
第7页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第8页
第8页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第9页
第9页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第10页
第10页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第11页
第11页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第12页
第12页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第13页
第13页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第14页
第14页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第15页
第15页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第16页
第16页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第17页
第17页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第18页
第18页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第19页
第19页 / 共27页
开源零听小清新范儿十足的音乐播放器代码案例.docx_第20页
第20页 / 共27页
亲,该文档总共27页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

开源零听小清新范儿十足的音乐播放器代码案例.docx

《开源零听小清新范儿十足的音乐播放器代码案例.docx》由会员分享,可在线阅读,更多相关《开源零听小清新范儿十足的音乐播放器代码案例.docx(27页珍藏版)》请在冰点文库上搜索。

开源零听小清新范儿十足的音乐播放器代码案例.docx

开源零听小清新范儿十足的音乐播放器代码案例

angularbase64.jsmodule支持中文,AngularJS学习--服务ServiceAngularJS学习--服务Service

angular实现的form自动布局,算法的简单实现arduino距离传感器,arduino小车前进左右转代码,array_change_key_case:

返回字符串键名全,array_chunk:

将一个数组分解成包含多个一

[代码][Java]代码

packagetest;

importcanghailan.lang.Methods;

/**

*@authorcanghailan2012-03-1221:

53

*/

publicclassMethodLookupTest{

publicstaticvoidmain(String[]args)throwsException{

System.out.println(Methods.publicLookup().findMethod(

MethodLookupTest.class,

"x",

Object.class)

);//publicstaticvoidtest.MethodLookupTest.x(java.lang.Object)

System.out.println(Methods.publicLookup().findMethod(

MethodLookupTest.class,

"x",

int.class)

);//publicstaticvoidtest.MethodLookupTest.x(int)

System.out.println(Methods.publicLookup().findMethod(

MethodLookupTest.class,

"x",

Integer.class)

);//publicstaticvoidtest.MethodLookupTest.x(java.lang.Integer)

System.out.println(Methods.publicLookup().findMethod(

MethodLookupTest.class,

"x",

byte.class)

);//publicstaticvoidtest.MethodLookupTest.x(int)

System.out.println(Methods.publicLookup().findMethod(

MethodLookupTest.class,

"x",

Byte.class)

);//publicstaticvoidtest.MethodLookupTest.x(java.lang.Object)

System.out.println(Methods.publicLookup().findMethod(

MethodLookupTest.class,

"x",

String.class)

);//publicstaticvoidtest.MethodLookupTest.x(java.lang.Object)

}

//C语言实现有序集合intset结构

//C语言制作动态链接库.so文件

publicstaticvoidx(Objecto){}

publicstaticvoidx(into){}

publicstaticvoidx(Integero){}

}

[文件]Methods.java ~ 2KB    (10)[9][10]

packagecanghailan.lang;

importjava.lang.reflect.InvocationTargetException;

importjava.lang.reflect.Method;

/**

*@authorcanghailan2012-01-1323:

06

*/

publicclassMethods{

privatestaticfinalMethodLookuppublicLookup=newMethodLookup(1024);

publicstaticMethodLookuppublicLookup(){

returnpublicLookup;

}

publicstaticObjectinvoke(Objectobject,Stringname,Object...params)

throwsNoSuchMethodException,InvocationTargetException,IllegalAccessException{

Methodmethod=publicLookup.findMethod(

object.getClass(),

name,

MethodLookup.getParameterTypes(params)

);

if(method!

=null){

returnmethod.invoke(object,params);

}

thrownewNoSuchMethodException(invokeToString(object.getClass(),name,params));

}

publicstaticObjectinvokeStatic(Class

>clazz,Stringname,Object...params)

throwsNoSuchMethodException,InvocationTargetException,IllegalAccessException{

Methodmethod=publicLookup.findMethod(

clazz,

name,

MethodLookup.getParameterTypes(params)

);

if(method!

=null){

returnmethod.invoke(null,params);

}

thrownewNoSuchMethodException(invokeToString(clazz,name,params));

}

privatestaticStringinvokeToString(Class

>clazz,Stringmethod,Object...params){

StringBuilderbuffer=newStringBuilder();

buffer.append(clazz.getName()).append('$');

buffer.append(method).append('(');

for(Objectparam:

params){

buffer.append(param).append(",");

}

buffer.setLength(buffer.length()-",".length());

buffer.append(')');

returnbuffer.toString();

}

}

[文件]Fields.java ~ 4KB    (10)[9][10]

packagecanghailan.lang;

importjava.lang.reflect.Field;

importjava.lang.reflect.InvocationTargetException;

importjava.lang.reflect.Method;

importjava.lang.reflect.Modifier;

/**

*@authorcanghailan2012-01-1323:

06

*/

publicclassFields{

privatestaticfinalFieldLookuplookup=newFieldLookup(1024);

publicstaticFieldLookuplookup(){

returnlookup;

}

publicstaticObjectget(Objectobject,Stringfield)

throwsNoSuchMethodException,InvocationTargetException,IllegalAccessException{

Methodgetter=lookup.findGetter(object.getClass(),field);

if(getter!

=null){

returngetter.invoke(object);

}

thrownewNoSuchMethodException("Couldnotfindgetterfor"+object.getClass().getName()+"."+field);

}

publicstaticvoidset(Objectobject,Stringfield,Objectvalue)

throwsNoSuchMethodException,InvocationTargetException,IllegalAccessException{

StringBuilderbuffer=newStringBuilder("set".length()+field.length());

buffer.append("set").append(field)

.setCharAt("set".length(),Character.toUpperCase(field.charAt(0)));

Methods.invoke(object,buffer.toString(),value);

}

publicstaticObjectdirectGet(Objectobject,Stringname)

throwsNoSuchFieldException,IllegalAccessException{

Fieldfield=lookup.findField(object.getClass(),name);

if(field!

=null){

returndirectGet(object,field);

}

thrownewNoSuchFieldException(object.getClass().getName()+"."+name);

}

publicstaticObjectdirectGet(Objectobject,Fieldfield)

throwsIllegalAccessException{

if(field.isAccessible()){

returnfield.get(object);

}else{

field.setAccessible(true);

Objectvalue=field.get(object);

field.setAccessible(false);

returnvalue;

}

}

publicstaticvoiddirectSet(Objectobject,Stringname,Objectvalue)

throwsNoSuchFieldException,IllegalAccessException{

Fieldfield=lookup.findField(object.getClass(),name);

if(field!

=null){

directSet(object,field,value);

}

thrownewNoSuchFieldException(object.getClass().getName()+"."+name);

}

publicstaticvoiddirectSet(Objectobject,Fieldfield,Objectvalue)

throwsIllegalAccessException{

if(field.isAccessible()){

field.set(object,value);

}else{

field.setAccessible(true);

field.set(object,value);

field.setAccessible(false);

}

}

publicstaticvoidcopy(Objectsrc,Objectdst,String...fieldNames)

throwsNoSuchFieldException,IllegalAccessException,InvocationTargetException,NoSuchMethodException{

if(src.getClass().equals(dst.getClass())){

for(StringfieldName:

fieldNames){

Fieldfield=lookup.findField(src.getClass(),fieldName);

if(field==null){

thrownewNoSuchFieldException(src.getClass().getName()+"."+fieldName);

}

directSet(dst,field,directGet(src,field));

}

}else{

for(Stringname:

fieldNames){

set(dst,name,get(src,name));

}

}

}

publicstaticvoidcopy(Tsrc,Tdst)throwsIllegalAccessException{

for(Class

>clz=src.getClass();clz!

=null;clz=clz.getSuperclass()){

for(Fieldfield:

clz.getDeclaredFields()){

//skipstaticandfinalfield

if(Modifier.isStatic(field.getModifiers())||

Modifier.isFinal(field.getModifiers())){

continue;

}

directSet(dst,field,directGet(src,field));

}

}

}

}

[文件]MethodLookup.java ~ 12KB    (10)[9][10]

packagecanghailan.lang;

importjava.lang.reflect.Method;

importjava.util.*;

/**

*@authorcanghailan2012-02-2320:

31

*/

publicclassMethodLookup

extendsCachedLookup

implementsMemberLookup{

publicstaticfinalClass

>[]EMPTY_CLASSES=newClass

>[0];

publicMethodLookup(Mapcache){

super(cache);

}

publicMethodLookup(finalintcacheSize){

super(cacheSize);

}

@Override

protectedMethodsInfodoFind(Identifierkey){

returnnewMethodsInfo(key.getClazz(),key.getName());

}

publicMethodfindMethod(Class

>clazz,Stringname,Class...actual){

MethodInfoaccept=null;

for(MethodInfomethodInfo:

find(newIdentifier(clazz,name)).getMethods(actual.length)){

intdiff=methodInfo.accept(actual);

if(diff==0){

returnmethodInfo.getMethod();

}

if(diff>0){

if(accept==null||methodInfo.isMorePrecise(accept)){

accept=methodInfo;

}

}

}

returnaccept==null?

null:

accept.getMethod();

}

/**

*

    *

  • null=>null
  • *

  • object=>object.getClass()
  • *

*/

publicstaticClass

>[]getParameterTypes(Object...params){

if(params==null){

returnnull;

}

if(params.length==0){

returnEMPTY_CLASSES;

}

Class

>[]types=newClass

>[params.length];

for(inti=0;i

types[i]=params[i]==null?

null:

params[i].getClass();

}

returntypes;

}

staticclassMethodsInfo{

staticfinalMethodInfo[]EMPTY_METHODS=newMethodInfo[0];

finalMethodInfo[][]methods;

MethodsInfo(Class

>clazz,Stringname){

methods=generateMethodsInfo(clazz,name);

}

MethodInfo[][]generateMethodsInfo(Class

>clazz,Stringname){

intmaxParameterLength=0;

Map>methodsInfoMap=newHashMap<>();

for(Methodmethod:

clazz.getMethods()){

if(method.getName().equals(name)){

intparameterLength=method.getParameterTypes().length;

ListmethodInfoList=methodsInfoMap.get(parameterLength);

if(methodInfoList==null){

methodInfoList=newLinkedList<>();

methodsInfoMap.put(parameterLength,methodInfoList);

}

methodInfoList.add(newMethodInfo(method));

maxParameterLength=Math.max(maxParameterLength,parameterLength);

}

}

MethodInfo[][]methods=newMethodInfo[maxParameterLength+1][];

for(inti=0;i

ListmethodInfoList=methodsInfoMap.get(i);

if(methodInfoList==null||methodInfoList.size()==0){

methods[i]=EMPTY_METHODS;

}else{

methods[i]=methodInfoList.toArray(newMethodInfo[methodInfoList.size()]);

}

}

returnmethods;

}

MethodInfo[]getMethods(intparameterLength){

if(parameterLength

returnmethods[parameterLength];

}

returnEMPTY_METHODS;

}

publicStringtoString(){

StringBuilderbuffer=newStringBuilder();

for(inti=0;i

buffer.append(i).append('\t')

.append(Arrays.toString(methods[i])).append('\n');

}

returnbuffer.toString();

}

}

staticclassMethodInfo{

finalMethodmethod;

ParameterTypesparameterTypes;//cache

MethodInfo(Methodmethod){

this.method=method;

}

MethodgetMethod(){

returnmethod;

}

ParameterTypesgetParamete

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 农林牧渔 > 林学

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2