public static String nameToPath(final String s) { return toValidName(s).replace('.', File.separatorChar); }
public static String toCName(final String s) { return toValidName(s).replace('.', '_'); }
/** * Returns the absolute path corresponding to the given fully qualified name * followed by the given suffix. * * @param fullyQualifiedName a fully qualified name * @param suffix a suffix to add to the fully qualified name.May be * <code>null</code> * @param extension the file extension to add at the end of the returned path. * May be <code>null</code> * @return the absolute path corresponding to the given fully qualified name. */ public static String fullyQualifiedNameToPath( final String fullyQualifiedName, final String suffix, final String extension) { String path = "/" + toValidName(fullyQualifiedName).replace('.', '/'); if (suffix != null) { path += suffix; } if (extension != null) { if (!extension.startsWith(".")) path += "."; path += extension; } return path; } }
/** * A static method that returns the name of the file that is generated by this * component for the given {@link InstancesDescriptor}; * * @param instanceDesc an {@link InstancesDescriptor} node. * @return the name of the file that is generated by this component for the * given {@link Definition}; */ public static String getInstancesFileName( final InstancesDescriptor instanceDesc) { String outputFileName = toValidName(instanceDesc.topLevelDefinition .getName()); outputFileName += "_" + toValidName(instanceDesc.instanceDefinition.getName()).replace('.', '_') + "_instances"; outputFileName = fullyQualifiedNameToPath(outputFileName, FILE_EXT); return outputFileName; }
/** * Returns the directory name that correspond to the package name of the given * fully qualified name. * * @param fullyQualifiedName a fully qualified name * @return the directory name that correspond to the package name of the given * fully qualified name. */ public static String fullyQualifiedNameToDirName( final String fullyQualifiedName) { final String packageName = getPackageName(toValidName(fullyQualifiedName)); if (packageName == null) return "/"; return packageNameToDirName(packageName); }
final String previousName = (String) map.put(toValidName(name), name); if (previousName != null && !previousName.equals(name)) { throw new CompilerError(GenericErrors.INTERNAL_ERROR,