| /******************************************************************************* |
| * Copyright (c) 30.03.2012 Aaron Digulla. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Aaron Digulla - initial API and implementation and/or initial documentation |
| *******************************************************************************/ |
| |
| // Custom DSL Descriptor for your MT4E |
| |
| currentType( subType( 'java.io.File' ) ).accept { |
| method name: 'makedirs', type: Void, provider: 'MopSetup', doc: 'Create directories recursively unless they already exist' |
| method name: 'usefulDelete', type: Void, provider: 'MopSetup', doc: 'Delete a file if it exists. Throws exception when the target is a folder' |
| method name: 'usefulRename', type: Void, provider: 'MopSetup', doc: 'Rename a file. Throws exception when the operation fails' |
| method name: 'copy', type: Void, params: [target: File], provider: 'MopSetup', doc: 'Copy a file or folder' |
| method name: 'normalize', type: String, provider: 'MopSetup', doc: 'Normalize a path: Make it canonical and replace the file separator char with slash (/)' |
| method name: 'pathRelativeTo', type: String, params: [parent: File], provider: 'MopSetup', doc: 'Return a path relative to a parent folder' |
| method name: 'isChildOf', type: String, params: [parent: File], provider: 'MopSetup', doc: 'True if the file is below the parent in the file system' |
| method name: 'unzip', type: String, params: [target: File], provider: 'MopSetup', doc: 'Unpack a ZIP archive into a target folder. The folder is created if necessary' |
| method name: 'untar', type: String, params: [target: File], provider: 'MopSetup', doc: 'Unpack a TAR archive into a target folder. The folder is created if necessary. The archive may be compressed (.tar.gz or .tar.bz2)' |
| } |
| |
| currentType( subType( 'java.lang.String' ) ).accept { |
| method name: 'removeStart', type: String, params: [pattern: String], provider: 'MopSetup', doc: 'Remove a pattern if it exists at the start of a string' |
| method name: 'removeEnd', type: String, params: [pattern: String], provider: 'MopSetup', doc: 'Remove a pattern if it exists at the end of a string' |
| method name: 'substringAfter', type: String, params: [pattern: String], provider: 'MopSetup', doc: 'Return the part of a String after the first occurrence of a pattern' |
| method name: 'substringAfterLast', type: String, params: [pattern: String], provider: 'MopSetup', doc: 'Return the part of a String after the last occurrence of a pattern' |
| method name: 'substringBefore', type: String, params: [pattern: String], provider: 'MopSetup', doc: 'Return the part of a String before the first occurrence of a pattern' |
| method name: 'substringBeforeLast', type: String, params: [pattern: String], provider: 'MopSetup', doc: 'Return the part of a String before the last occurrence of a pattern' |
| method name: 'endsWithOneOf', type: String, params: [pattern: String[]], provider: 'MopSetup', doc: 'True if the string ends with one of the supplied patterns. If no patterns are supplied, return false' |
| } |
| |
| currentType( subType( 'java.util.zip.ZipFile' ) ).accept { |
| method name: 'eachEntry', type: java.util.zip.ZipEntry, params: [c: Closure], provider: 'MopSetup', doc: 'Invoke closure for each entry in the ZIP archive' |
| method name: 'withInputStream', type: InputStream, params: [entry: java.util.zip.ZipEntry, c: Closure], provider: 'MopSetup', doc: 'Invoke closure with the input stream for the entry. Afterwards, the stream will be closed' |
| } |