-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parse source code from resource folder
- Loading branch information
Showing
9 changed files
with
158 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
jParser/base/src/main/java/com/github/xpenatan/jparser/base/helper/BoolArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.xpenatan.jparser.base.helper; | ||
|
||
public class BoolArray { | ||
public void copy(double [] array) { | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
jParser/base/src/main/java/com/github/xpenatan/jparser/base/helper/CharArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package com.github.xpenatan.jparser.base.helper; | ||
|
||
public class CharArray { | ||
public void copy(double [] array) { | ||
|
||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
jParser/base/src/main/java/com/github/xpenatan/jparser/base/helper/DoubleArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.github.xpenatan.jparser.base.helper; | ||
|
||
import com.github.xpenatan.jparser.base.IDLBase; | ||
|
||
public class DoubleArray extends IDLBase { | ||
public void copy(double [] array) { | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
jParser/base/src/main/java/com/github/xpenatan/jparser/base/helper/FloatArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.github.xpenatan.jparser.base.helper; | ||
|
||
import com.github.xpenatan.jparser.base.IDLBase; | ||
|
||
public class FloatArray extends IDLBase { | ||
|
||
public void copy(float [] array) { | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
jParser/base/src/main/java/com/github/xpenatan/jparser/base/helper/IntArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.github.xpenatan.jparser.base.helper; | ||
|
||
import com.github.xpenatan.jparser.base.IDLBase; | ||
|
||
public class IntArray extends IDLBase { | ||
|
||
public void copy(int [] array) { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
jParser/idl/src/main/java/com/github/xpenatan/jparser/idl/ResourceList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
package com.github.xpenatan.jparser.idl; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Enumeration; | ||
import java.util.regex.Pattern; | ||
import java.util.zip.ZipEntry; | ||
import java.util.zip.ZipException; | ||
import java.util.zip.ZipFile; | ||
|
||
// Class from https://stackoverflow.com/questions/3923129/get-a-list-of-resources-from-classpath-directory | ||
public class ResourceList { | ||
|
||
public static Collection<String> getResources( | ||
final Pattern pattern){ | ||
final ArrayList<String> retval = new ArrayList<>(); | ||
final String classPath = System.getProperty("java.class.path", "."); | ||
final String[] classPathElements = classPath.split(System.getProperty("path.separator")); | ||
for(final String element : classPathElements){ | ||
retval.addAll(getResources(element, pattern)); | ||
} | ||
return retval; | ||
} | ||
|
||
private static Collection<String> getResources( | ||
final String element, | ||
final Pattern pattern){ | ||
final ArrayList<String> retval = new ArrayList<String>(); | ||
final File file = new File(element); | ||
if(file.isDirectory()){ | ||
retval.addAll(getResourcesFromDirectory(file, pattern)); | ||
} else{ | ||
retval.addAll(getResourcesFromJarFile(file, pattern)); | ||
} | ||
return retval; | ||
} | ||
|
||
private static Collection<String> getResourcesFromJarFile( | ||
final File file, | ||
final Pattern pattern){ | ||
final ArrayList<String> retval = new ArrayList<String>(); | ||
ZipFile zf; | ||
try{ | ||
zf = new ZipFile(file); | ||
} catch(final ZipException e){ | ||
throw new Error(e); | ||
} catch(final IOException e){ | ||
throw new Error(e); | ||
} | ||
final Enumeration e = zf.entries(); | ||
while(e.hasMoreElements()){ | ||
final ZipEntry ze = (ZipEntry) e.nextElement(); | ||
final String fileName = ze.getName(); | ||
final boolean accept = pattern.matcher(fileName).matches(); | ||
if(accept){ | ||
retval.add(fileName); | ||
} | ||
} | ||
try{ | ||
zf.close(); | ||
} catch(final IOException e1){ | ||
throw new Error(e1); | ||
} | ||
return retval; | ||
} | ||
|
||
private static Collection<String> getResourcesFromDirectory( | ||
final File directory, | ||
final Pattern pattern){ | ||
final ArrayList<String> retval = new ArrayList<String>(); | ||
final File[] fileList = directory.listFiles(); | ||
for(final File file : fileList){ | ||
if(file.isDirectory()){ | ||
retval.addAll(getResourcesFromDirectory(file, pattern)); | ||
} else{ | ||
try{ | ||
final String fileName = file.getCanonicalPath(); | ||
final boolean accept = pattern.matcher(fileName).matches(); | ||
if(accept){ | ||
retval.add(fileName); | ||
} | ||
} catch(final IOException e){ | ||
throw new Error(e); | ||
} | ||
} | ||
} | ||
return retval; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters