jodd-madvoc/src/main/java/jodd/madvoc/component/RootPackages.java
public void addRootPackage(final String rootPackage, String mapping) {
		if (packages == null) {
			packages = new String[0];
		}
		if (mappings == null) {
			mappings = new String[0];
		}

		// fix mapping
		if (mapping.length() > 0) {
			// mapping must start with the slash
			if (!mapping.startsWith(StringPool.SLASH)) {
				mapping = StringPool.SLASH + mapping;
			}
			// mapping must NOT end with the slash
			if (mapping.endsWith(StringPool.SLASH)) {
				mapping = StringUtil.substring(mapping, 0, -1);
			}
		}

		// detect duplicates
		for (int i = 0; i < packages.length; i++) {
			if (packages[i].equals(rootPackage)) {
				if (mappings[i].equals(mapping)) {
					// both package and the mappings are the same
					return;
				}
				throw new MadvocException("Different mappings for the same root package: " + rootPackage);
			}
		}

		packages = ArraysUtil.append(packages, rootPackage);
		mappings = ArraysUtil.append(mappings, mapping);
	}
public void addRootPackage(final String rootPackage, String mapping) {
		if (packages == null) {
			packages = new String[0];
		}
		if (mappings == null) {
			mappings = new String[0];
		}

		// fix mapping
		if (mapping.length() > 0) {
			// mapping must start with the slash
			if (!mapping.startsWith(StringPool.SLASH)) {
				mapping = StringPool.SLASH + mapping;
			}
			// mapping must NOT end with the slash
			if (mapping.endsWith(StringPool.SLASH)) {
				mapping = StringUtil.substring(mapping, 0, -1);
			}
		}

		// detect duplicates
		for (int i = 0; i < packages.length; i++) {
			if (packages[i].equals(rootPackage)) {
				if (mappings[i].equals(mapping)) {
					// both package and the mappings are the same
					return;
				}
				throw new MadvocException("Different mappings for the same root package: " + rootPackage);
			}
		}

		packages = ArraysUtil.append(packages, rootPackage);
		mappings = ArraysUtil.append(mappings, mapping);
	}
public void addRootPackage ( final String rootPackage , String mapping ) { if ( packages == null ) { packages = new String [ 0 ] ; } if ( mappings == null ) { mappings = new String [ 0 ] ; } // fix mapping if ( mapping . length ( ) > 0 ) { // mapping must start with the slash if ( ! mapping . startsWith ( StringPool . SLASH ) ) { mapping = StringPool . SLASH + mapping ; } // mapping must NOT end with the slash if ( mapping . endsWith ( StringPool . SLASH ) ) { mapping = StringUtil . substring ( mapping , 0 , - 1 ) ; } } // detect duplicates for ( int i = 0 ; i < packages . length ; i ++ ) { if ( packages [ i ] . equals ( rootPackage ) ) { if ( mappings [ i ] . equals ( mapping ) ) { // both package and the mappings are the same return ; } throw new MadvocException ( "Different mappings for the same root package: " + rootPackage ) ; } } packages = ArraysUtil . append ( packages , rootPackage ) ; mappings = ArraysUtil . append ( mappings , mapping ) ; }
Adds root package and its path mapping. Duplicate root packages
are ignored, if mapping path is equals, otherwise exception is thrown.
Adds root package and its path mapping . Duplicate root packages are ignored if mapping path is equals otherwise exception is thrown .