Example usage for org.apache.commons.lang3 StringUtils isNumeric

List of usage examples for org.apache.commons.lang3 StringUtils isNumeric

Introduction

In this page you can find the example usage for org.apache.commons.lang3 StringUtils isNumeric.

Prototype

public static boolean isNumeric(final CharSequence cs) 

Source Link

Document

Checks if the CharSequence contains only Unicode digits.

Usage

From source file:com.floreantpos.bo.ui.explorer.MenuItemExplorer.java

private String doDuplicateName(MenuItem existingItem) {
    String existingName = existingItem.getName();
    String newName = new String();
    int lastIndexOf = existingName.lastIndexOf(" ");
    if (lastIndexOf == -1) {
        newName = existingName + " 1";
    } else {/* ww w.  j  a va  2s .c  o  m*/
        String processName = existingName.substring(lastIndexOf + 1, existingName.length());
        if (StringUtils.isNumeric(processName)) {
            Integer count = Integer.valueOf(processName);
            count += 1;
            newName = existingName.replace(processName, String.valueOf(count));
        } else {
            newName = existingName + " 1";
        }
    }
    return newName;
}

From source file:com.streamsets.pipeline.lib.jdbc.multithread.TableContextUtil.java

public static Timestamp getTimestampForOffsetValue(String offsetValue) {
    final String[] parts = StringUtils.splitByWholeSeparator(offsetValue, OFFSET_VALUE_NANO_SEPARATOR);
    Utils.checkState(parts.length <= 2,
            String.format(/* w ww.j  a  va2  s.  c  om*/
                    "offsetValue of %s invalid; should contain at most one occurence of nanos separator %s",
                    offsetValue, OFFSET_VALUE_NANO_SEPARATOR));

    final long millis = Long.parseLong(parts[0]);
    Timestamp timestamp = new Timestamp(millis);

    if (parts.length == 2) {
        final String nanosStr = parts[1];
        if (StringUtils.isNotBlank(nanosStr) && StringUtils.isNumeric(nanosStr)) {
            final int nanos = Integer.parseInt(nanosStr) % JdbcUtil.NANOS_TO_MILLIS_ADJUSTMENT;
            // in a Timestamp, nanos also includes the millisecond portion, so we need to incorporate that
            final long nanosFromMillis = millis % 1000;
            timestamp.setNanos(((int) nanosFromMillis * JdbcUtil.NANOS_TO_MILLIS_ADJUSTMENT) + nanos);
        }
    }

    return timestamp;
}

From source file:com.simpligility.maven.plugins.android.AbstractEmulatorMojo.java

/**
 * This method extracts a port number from the serial number of a device.
 * It assumes that the device name is of format [xxxx-nnnn] where nnnn is the
 * port number.// w  w  w.j  a  v a2  s  .  c o m
 *
 * @param device The device to extract the port number from.
 * @return Returns the port number of the device
 */
private int extractPortFromDevice(IDevice device) {
    String portStr = StringUtils.substringAfterLast(device.getSerialNumber(), "-");
    if (StringUtils.isNotBlank(portStr) && StringUtils.isNumeric(portStr)) {
        return Integer.parseInt(portStr);
    }

    //If the port is not available then return -1
    return -1;
}

From source file:forge.game.GameActionUtil.java

public static String generatedMana(final SpellAbility sa) {
    // Calculate generated mana here for stack description and resolving

    int amount = sa.hasParam("Amount")
            ? AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParam("Amount"), sa)
            : 1;/*from ww  w.ja v a 2 s .c  o  m*/

    AbilityManaPart abMana = sa.getManaPart();
    String baseMana;
    if (abMana.isComboMana()) {
        baseMana = abMana.getExpressChoice();
        if (baseMana.isEmpty()) {
            baseMana = abMana.getOrigProduced();
        }
    } else if (abMana.isAnyMana()) {
        baseMana = abMana.getExpressChoice();
        if (baseMana.isEmpty()) {
            baseMana = "Any";
        }
    } else if (sa.getApi() == ApiType.ManaReflected) {
        baseMana = abMana.getExpressChoice();
    } else if (abMana.isSpecialMana()) {
        baseMana = abMana.getExpressChoice();
    } else {
        baseMana = abMana.mana();
    }

    if (sa.hasParam("Bonus")) {
        // For mana abilities that get a bonus
        // Bonus currently MULTIPLIES the base amount. Base Amounts should
        // ALWAYS be Base
        int bonus = 0;
        if (sa.getParam("Bonus").equals("UrzaLands")) {
            if (hasUrzaLands(sa.getActivatingPlayer())) {
                bonus = Integer.parseInt(sa.getParam("BonusProduced"));
            }
        }

        amount += bonus;
    }

    if (sa.getSubAbility() != null) {
        // Mark SAs with subAbilities as undoable. These are generally things like damage, and other stuff
        // that's hard to track and remove
        sa.setUndoable(false);
    } else {
        try {
            if ((sa.getParam("Amount") != null) && (amount != Integer.parseInt(sa.getParam("Amount")))) {
                sa.setUndoable(false);
            }
        } catch (final NumberFormatException n) {
            sa.setUndoable(false);
        }
    }

    final StringBuilder sb = new StringBuilder();
    if (amount == 0) {
        sb.append("0");
    } else if (abMana.isComboMana()) {
        // amount is already taken care of in resolve method for combination mana, just append baseMana
        sb.append(baseMana);
    } else {
        if (StringUtils.isNumeric(baseMana)) {
            sb.append(amount * Integer.parseInt(baseMana));
        } else {
            sb.append(baseMana);
            for (int i = 1; i < amount; i++) {
                sb.append(" ").append(baseMana);
            }
        }
    }
    return sb.toString();
}

From source file:chibi.gemmaanalysis.LinkEvalCli.java

@Override
protected void processOptions() {
    super.processOptions();
    initBeans();/*from   ww  w .  j  ava  2s .  c o m*/
    String commonName = getOptionValue('t');
    if (StringUtils.isBlank(commonName)) {
        System.out.println("MUST enter a valid taxon!");
        System.exit(0);
    }
    if (!StringUtils.equalsIgnoreCase("mouse", commonName) && !StringUtils.equalsIgnoreCase("rat", commonName)
            && !StringUtils.equalsIgnoreCase("human", commonName)) {
        System.out.println("MUST enter a valid taxon!");
        System.exit(0);
    }

    this.taxon = taxonService.findByCommonName(commonName);
    if (taxon == null) {
        System.out.println("Taxon " + commonName + " not found.");
        System.exit(0);
    }
    String input = getOptionValue('d');
    if (StringUtils.isBlank(input)) {
        System.out.println("You MUST enter a valid filename OR size of dataset");
        System.exit(0);
    }
    this.adShortName = getOptionValue("array");
    if (StringUtils.isBlank(this.adShortName)) {
        System.out.println("You MUST enter the shortname for the associated platform");
        System.exit(0);
    }
    if (StringUtils.isNumeric(input)) {// set size entered
        if (this.adShortName.equals("n/a")) {
            this.randomFromTaxon = true;
        } else {
            this.randomFromArray = true;
        }

        SET_SIZE = Integer.parseInt(input);
        if (SET_SIZE < 1) {
            System.out.println("Random set size must be a positive integer");
            System.exit(0);
        }
        System.out.println("Will create a set of " + SET_SIZE + " random gene pairs!");
        if (this.hasOption("runs")) {
            String runs = getOptionValue("runs");
            if (StringUtils.isNumeric(runs)) {
                numberOfRandomRuns = Integer.parseInt(runs);
                if (numberOfRandomRuns < 1) {
                    System.out.println("Number of random runs must be a positive integer");
                    System.exit(0);
                }
            } else {
                System.out.println("Number of random runs must be a numeric value");
                System.exit(0);
            }
        }
    } else {// path to input file entered
        File f = new File(input);
        if (f.canRead()) {
            this.file_path = input;
            if (this.hasOption("subset")) {
                String size = getOptionValue("subset");
                if (StringUtils.isNumeric(size)) {
                    this.subsetSize = Double.parseDouble(size);
                    this.selectSubset = true;
                    log.info("Approximate subset of scores desired");
                } else {
                    System.out.println("Subset size must be a numeric value");
                    System.exit(0);
                }
            }
        } else {
            System.out.println(
                    input + "is NOT a valid filename! You MUST enter a valid filename OR size of dataset");
            System.exit(0);
        }
    }
    if (hasOption('x')) {
        String maxs = getOptionValue('x');
        if (maxs.equalsIgnoreCase("MAX"))
            this.max = true;
        else
            this.max = false;
    }

    if (hasOption('w')) {
        String weights = getOptionValue('w');
        if (weights.equalsIgnoreCase("weight"))
            this.weight = true;
        else
            this.weight = false;
    }

    if (hasOption("termsout")) {
        this.termsOutPath = getOptionValue("termsout");
        log.info("GO mapping will be saved as tabbed text to " + this.termsOutPath);
    }

    if (hasOption('m')) {
        String metricName = getOptionValue('m');
        if (metricName.equalsIgnoreCase("resnik"))
            this.metric = GoMetric.Metric.resnik;
        else if (metricName.equalsIgnoreCase("lin"))
            this.metric = GoMetric.Metric.lin;
        else if (metricName.equalsIgnoreCase("jiang"))
            this.metric = GoMetric.Metric.jiang;
        else if (metricName.equalsIgnoreCase("percent"))
            this.metric = GoMetric.Metric.percent;
        else if (metricName.equalsIgnoreCase("cosine"))
            this.metric = GoMetric.Metric.cosine;
        else if (metricName.equalsIgnoreCase("kappa"))
            this.metric = GoMetric.Metric.kappa;
        else {
            this.metric = GoMetric.Metric.simple;
            this.max = false;
        }
    }

    if (this.hasOption("g1col")) {
        this.firstProbeColumn = getIntegerOptionValue("g1col");
    }

    if (this.hasOption("g2col")) {
        this.secondProbeColumn = getIntegerOptionValue("g2col");
    }

    if (this.hasOption("noZeroGo")) {
        this.noZeros = true;
    }

    if (this.hasOption("print")) {
        this.printRandomLinks = true;
        this.outRandLinksFile = getOptionValue("print");
        if (StringUtils.isBlank(outRandLinksFile)) {
            System.out.println("You must enter an output file path for printing random probe pairs");
            System.exit(0);
        }
    }

    if (this.hasOption("probenames")) {
        this.randomFromSubset = true;
        this.probenames_file_path = getOptionValue("probenames");
    }

    if (this.hasOption("aspect")) {
        String aspect = getOptionValue("aspect");
        if (aspect.equals("mf")) {
            this.goAspectToUse = GOAspect.MOLECULAR_FUNCTION;
        } else if (aspect.equals("bp")) {
            this.goAspectToUse = GOAspect.BIOLOGICAL_PROCESS;
        } else if (aspect.equals("cc")) {
            this.goAspectToUse = GOAspect.CELLULAR_COMPONENT;

        } else {
            System.out.println("Aspect must be one of bp, mf or cc");
            System.exit(0);
        }
    }

    outFile = getOptionValue('o');
    initGO();
}

From source file:com.moviejukebox.reader.MovieNFOReader.java

/**
 * Parse a single episode detail element
 *
 * @param movie//  w w w .ja  v a  2  s. c o m
 * @param eEpisodeDetails
 * @return
 */
private static EpisodeDetail parseSingleEpisodeDetail(Element eEpisodeDetails) {
    EpisodeDetail epDetail = new EpisodeDetail();
    if (eEpisodeDetails == null) {
        return epDetail;
    }

    epDetail.setTitle(DOMHelper.getValueFromElement(eEpisodeDetails, "title"));

    String tempValue = DOMHelper.getValueFromElement(eEpisodeDetails, "season");
    if (StringUtils.isNumeric(tempValue)) {
        epDetail.setSeason(Integer.parseInt(tempValue));
    }

    tempValue = DOMHelper.getValueFromElement(eEpisodeDetails, "episode");
    if (StringUtils.isNumeric(tempValue)) {
        epDetail.setEpisode(Integer.parseInt(tempValue));
    }

    epDetail.setPlot(DOMHelper.getValueFromElement(eEpisodeDetails, "plot"));

    tempValue = DOMHelper.getValueFromElement(eEpisodeDetails, "rating");
    int rating = parseRating(tempValue);
    if (rating > -1) {
        // Looks like a valid rating
        epDetail.setRating(String.valueOf(rating));
    }

    tempValue = DOMHelper.getValueFromElement(eEpisodeDetails, "aired");
    if (isValidString(tempValue)) {
        try {
            epDetail.setFirstAired(DateTimeTools.convertDateToString(new DateTime(tempValue)));
        } catch (Exception ignore) {
            // Set the aired date if there is an exception
            epDetail.setFirstAired(tempValue);
        }
    }

    epDetail.setAirsAfterSeason(
            DOMHelper.getValueFromElement(eEpisodeDetails, "airsafterseason", "airsAfterSeason"));
    epDetail.setAirsBeforeSeason(
            DOMHelper.getValueFromElement(eEpisodeDetails, "airsbeforeseason", "airsBeforeSeason"));
    epDetail.setAirsBeforeEpisode(
            DOMHelper.getValueFromElement(eEpisodeDetails, "airsbeforeepisode", "airsBeforeEpisode"));

    return epDetail;
}

From source file:eu.europa.ec.fisheries.uvms.spatial.service.bean.impl.AreaServiceBean.java

@Override
public Map<String, Object> getLocationDetails(final LocationTypeEntry locationTypeEntry)
        throws ServiceException {

    BaseAreaEntity match = null;//from w w  w.j  av a2 s  .c o m

    GeodeticCalculator calc = new GeodeticCalculator(GeometryUtils.toDefaultCoordinateReferenceSystem());
    String id = locationTypeEntry.getId();
    String locationType = locationTypeEntry.getLocationType();
    AreaLocationTypesEntity locationTypesEntity;
    Double incomingLatitude = locationTypeEntry.getLatitude();
    Double incomingLongitude = locationTypeEntry.getLongitude();

    if (id != null && !StringUtils.isNumeric(id)) {
        throw new SpatialServiceException(SpatialServiceErrors.INVALID_ID_TYPE, id);
    }

    locationTypesEntity = repository.findAreaLocationTypeByTypeName(locationType.toUpperCase());

    if (locationTypesEntity == null) {
        throw new ServiceException("TYPE CANNOT BE NULL");
    } else if (!locationTypesEntity.getIsLocation()) {
        throw new ServiceException(locationTypesEntity.getTypeName() + " IS NOT A LOCATION");
    }

    if (locationTypeEntry.getId() != null) {
        AbstractAreaDao dao = DAOFactory.getAbstractSpatialDao(em, locationTypesEntity.getTypeName());
        BaseAreaEntity areaEntity = dao.findOne(Long.parseLong(locationTypeEntry.getId()));
        if (areaEntity == null) {
            throw new SpatialServiceException(SpatialServiceErrors.ENTITY_NOT_FOUND,
                    locationTypesEntity.getTypeName());
        }
        match = areaEntity;
    } else {

        Point point = (Point) GeometryUtils.toGeographic(incomingLatitude, incomingLongitude,
                locationTypeEntry.getCrs());

        List<PortEntity> records = repository.listClosestPorts(point, 5);
        Double closestDistance = Double.MAX_VALUE;

        for (PortEntity portsEntity : records) {

            final Geometry geometry = portsEntity.getGeom();
            final Point centroid = geometry.getCentroid();
            calc.setStartingGeographicPoint(centroid.getX(), centroid.getY());
            calc.setDestinationGeographicPoint(point.getX(), point.getY());
            Double orthodromicDistance = calc.getOrthodromicDistance();

            if (closestDistance > orthodromicDistance) {
                closestDistance = orthodromicDistance;
                match = portsEntity;
            }
        }
    }
    ObjectMapper objectMapper = new ObjectMapper();
    Map map = objectMapper.convertValue(match, Map.class);
    return map;
}

From source file:com.omertron.slackbot.listeners.BoardGameListener.java

/**
 * Process the MeetUp details and present them
 *
 * @param session//ww w .java  2  s .  co  m
 * @param msgChannel
 * @param query
 */
private void commandMeetup(SlackSession session, SlackChannel msgChannel, String query) {
    int muQuantity = 1;
    boolean muDetailed = false;

    if (StringUtils.isNotBlank(query)) {
        LOG.info("Processing parameters");
        List<String> params = new ArrayList<>();
        if (query.contains(" ")) {
            params.addAll(Arrays.asList(query.split(" ")));
        } else {
            params.add(query);
        }

        LOG.info("Found {} parameters", params.size());

        for (String p : params) {
            if (StringUtils.isNumeric(p)) {
                muQuantity = NumberUtils.toInt(p, 1);
                continue;
            }

            if ("DETAILED".equalsIgnoreCase(p)) {
                muDetailed = true;
            }
        }
    }

    LOG.info("Quantity: {}", muQuantity);
    LOG.info("Detailed: {}", muDetailed);

    try {
        Meetup.readMeetUp(muQuantity);
    } catch (ApiException ex) {
        LOG.warn("Failed to read data from meetup: {}", ex.getMessage(), ex);
        com.omertron.slackbot.SlackBot.messageAdmins(session,
                "Failed to read data from meetup: " + ex.getMessage());
        return;
    }

    Meetup.getMeetupsDays(7, false);

    List<SlackAttachment> attach = Meetup.getMeetupsQty(muQuantity, muDetailed);
    SlackPreparedMessage preparedMessage = new SlackPreparedMessage.Builder().addAttachments(attach)
            .withMessage("These are the upcoming MeetUps:").build();
    session.sendMessage(msgChannel, preparedMessage);
}

From source file:com.moviejukebox.reader.MovieJukeboxXMLReader.java

/**
 * Parse a single movie detail XML file/*from w ww . java2  s  . co m*/
 *
 * @param xmlFile
 * @param movie
 * @return
 */
public boolean parseMovieXML(File xmlFile, Movie movie) {
    boolean forceDirtyFlag = Boolean.FALSE; // force dirty flag for example when extras have been deleted
    Document xmlDoc;

    try {
        xmlDoc = DOMHelper.getDocFromFile(xmlFile);
    } catch (MalformedURLException error) {
        LOG.error(ERROR_FIXIT, xmlFile.getName());
        LOG.error(SystemTools.getStackTrace(error));
        return Boolean.FALSE;
    } catch (IOException error) {
        LOG.error(ERROR_FIXIT, xmlFile.getName());
        LOG.error(SystemTools.getStackTrace(error));
        return Boolean.FALSE;
    } catch (ParserConfigurationException | SAXException error) {
        LOG.error(ERROR_FIXIT, xmlFile.getName());
        LOG.error(SystemTools.getStackTrace(error));
        return Boolean.FALSE;
    }

    NodeList nlMovies; // Main list of movies, there should only be 1
    Node nMovie; // Node for the movie

    NodeList nlElements; // Reusable NodeList for the other elements
    Node nElements; // Reusable Node for the other elements

    nlMovies = xmlDoc.getElementsByTagName(MOVIE);
    for (int loopMovie = 0; loopMovie < nlMovies.getLength(); loopMovie++) {
        nMovie = nlMovies.item(loopMovie);
        if (nMovie.getNodeType() == Node.ELEMENT_NODE) {
            Element eMovie = (Element) nMovie;

            // Get all the IDs associated with the movie
            nlElements = eMovie.getElementsByTagName("id");
            for (int looper = 0; looper < nlElements.getLength(); looper++) {
                nElements = nlElements.item(looper);
                if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                    Element eId = (Element) nElements;

                    String movieDb = eId.getAttribute(MOVIEDB);
                    if (StringTools.isNotValidString(movieDb)) {
                        movieDb = ImdbPlugin.IMDB_PLUGIN_ID;
                    }
                    movie.setId(movieDb, eId.getTextContent());
                }
            } // End of ID

            // Get the Version the XML was written with
            movie.setMjbVersion(DOMHelper.getValueFromElement(eMovie, "mjbVersion"));

            // Get the Git SHA the XML was written with
            movie.setMjbGitSHA(DOMHelper.getValueFromElement(eMovie, "mjbGitSHA"));

            // Get the date/time the XML was written
            movie.setMjbGenerationDateString(DOMHelper.getValueFromElement(eMovie, "xmlGenerationDate"));

            if (StringTools.isNotValidString(movie.getBaseFilename())) {
                movie.setBaseFilename(DOMHelper.getValueFromElement(eMovie, "baseFilenameBase"));
            }

            if (StringTools.isNotValidString(movie.getBaseName())) {
                movie.setBaseName(DOMHelper.getValueFromElement(eMovie, BASE_FILENAME));
            }

            // Get the title fields
            parseOverridableTitle(movie, eMovie);
            parseOverridableOriginalTitle(movie, eMovie);
            movie.setTitleSort(DOMHelper.getValueFromElement(eMovie, SORT_TITLE));

            // Get the year. We don't care about the attribute as that is the index
            parseOverridableYear(movie, eMovie);

            // Get the release date
            parseOverridableReleaseDate(movie, eMovie);

            // get the show status
            movie.setShowStatus(DOMHelper.getValueFromElement(eMovie, "showStatus"));

            // Get the ratings. We don't care about the RATING as this is a calulated value.
            // So just get the childnodes of the "ratings" node
            nlElements = eMovie.getElementsByTagName("ratings");
            if (nlElements.getLength() > 0) {
                nlElements = nlElements.item(0).getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element eRating = (Element) nElements;

                        String movieDb = eRating.getAttribute(MOVIEDB);
                        if (StringTools.isNotValidString(movieDb)) {
                            movieDb = ImdbPlugin.IMDB_PLUGIN_ID;
                        }
                        movie.addRating(movieDb, Integer.parseInt(eRating.getTextContent()));
                    }
                }
            } // End of Ratings

            // Get the watched flags
            movie.setWatchedNFO(Boolean.parseBoolean(DOMHelper.getValueFromElement(eMovie, "watchedNFO")));
            movie.setWatchedFile(Boolean.parseBoolean(DOMHelper.getValueFromElement(eMovie, "watchedFile")));

            // Get artwork URLS
            movie.setPosterURL(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "posterURL")));
            movie.setFanartURL(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "fanartURL")));
            movie.setBannerURL(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "bannerURL")));
            movie.setClearArtURL(HTMLTools.decodeHtml(DOMHelper.getValueFromElement(eMovie, "clearArtURL")));
            movie.setClearLogoURL(HTMLTools.decodeHtml(DOMHelper.getValueFromElement(eMovie, "clearLogoURL")));
            movie.setTvThumbURL(HTMLTools.decodeHtml(DOMHelper.getValueFromElement(eMovie, "tvThumbURL")));
            movie.setSeasonThumbURL(
                    HTMLTools.decodeHtml(DOMHelper.getValueFromElement(eMovie, "seasonThumbURL")));
            movie.setMovieDiscURL(HTMLTools.decodeHtml(DOMHelper.getValueFromElement(eMovie, "movieDiscURL")));

            // Get artwork files
            movie.setPosterFilename(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "posterFile")));
            movie.setDetailPosterFilename(
                    HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "detailPosterFile")));
            movie.setThumbnailFilename(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "thumbnail")));
            movie.setFanartFilename(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "fanartFile")));
            movie.setBannerFilename(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "bannerFile")));
            movie.setWideBannerFilename(
                    HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "wideBannerFile")));
            movie.setClearArtFilename(
                    HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "clearArtFile")));
            movie.setClearLogoFilename(
                    HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "clearLogoFile")));
            movie.setTvThumbFilename(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "tvThumbFile")));
            movie.setSeasonThumbFilename(
                    HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "seasonThumbFile")));
            movie.setMovieDiscFilename(
                    HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "movieDiscFile")));

            // Get the plot and outline
            parseOverridablePlot(movie, eMovie);
            parseOverridableOutline(movie, eMovie);

            // Get the quote
            parseOverridableQuote(movie, eMovie);

            // Get the tagline
            parseOverridableTagline(movie, eMovie);

            // Get the company name
            parseOverridableCompany(movie, eMovie);

            // get the runtime
            parseOverridableRuntime(movie, eMovie);

            // get the top 250
            parseOverridableTop250(movie, eMovie);

            // Get the directors
            nlElements = eMovie.getElementsByTagName("directors");
            if (nlElements.getLength() > 0) {
                Element tagElement = (Element) nlElements.item(0);
                nlElements = tagElement.getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element ePerson = (Element) nElements;
                        movie.addDirector(ePerson.getTextContent(), tagElement.getAttribute(SOURCE));
                    }
                }
            }

            // Get the writers
            nlElements = eMovie.getElementsByTagName("writers");
            if (nlElements.getLength() > 0) {
                Element tagElement = (Element) nlElements.item(0);
                nlElements = tagElement.getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element ePerson = (Element) nElements;
                        movie.addWriter(ePerson.getTextContent(), tagElement.getAttribute(SOURCE));
                    }
                }
            }

            // Get the cast
            nlElements = eMovie.getElementsByTagName("cast");
            if (nlElements.getLength() > 0) {
                Element tagElement = (Element) nlElements.item(0);
                nlElements = tagElement.getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element ePerson = (Element) nElements;
                        movie.addActor(ePerson.getTextContent(), tagElement.getAttribute(SOURCE));
                    }
                }
            }

            // Get the country
            parseOverridableCountry(movie, eMovie);

            // Get the genres
            nlElements = eMovie.getElementsByTagName("genres");
            if (nlElements.getLength() > 0) {
                Element tagElement = (Element) nlElements.item(0);
                nlElements = tagElement.getChildNodes();
                List<String> genres = new ArrayList<>();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element eGenre = (Element) nElements;
                        genres.add(eGenre.getTextContent());
                    }
                }
                movie.setGenres(genres, tagElement.getAttribute(SOURCE));
            }

            // Process the sets
            nlElements = eMovie.getElementsByTagName("sets");
            if (nlElements.getLength() > 0) {
                nlElements = nlElements.item(0).getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element eSet = (Element) nElements;
                        String order = eSet.getAttribute(ORDER);
                        if (StringTools.isValidString(order)) {
                            movie.addSet(eSet.getTextContent(), Integer.parseInt(order));
                        } else {
                            movie.addSet(eSet.getTextContent());
                        }
                    }
                }
            }

            // Get certification
            parseOverridableCertification(movie, eMovie);

            // Get language
            parseOverridableLanguage(movie, eMovie);

            // Get subtitles
            movie.setSubtitles(DOMHelper.getValueFromElement(eMovie, "subtitles"));

            // Get the TrailerExchange
            movie.setTrailerExchange(
                    DOMHelper.getValueFromElement(eMovie, "trailerExchange").equalsIgnoreCase(YES));

            // Get trailerLastScan date/time
            movie.setTrailerLastScan(DOMHelper.getValueFromElement(eMovie, TRAILER_LAST_SCAN));

            // Get file container
            parseOverridableContainer(movie, eMovie);

            nlElements = eMovie.getElementsByTagName("codecs");
            if (nlElements.getLength() > 0) {
                nlElements = nlElements.item(0).getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        String codecType = nElements.getNodeName();
                        if (nElements.getChildNodes().getLength() > 0) {
                            for (int cLooper = 0; cLooper < nElements.getChildNodes().getLength(); cLooper++) {
                                Node nCodec = nElements.getChildNodes().item(cLooper);
                                if (nCodec.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eCodec = (Element) nCodec;

                                    Codec codec;
                                    if (CodecType.VIDEO.toString().equalsIgnoreCase(codecType)) {
                                        codec = new Codec(CodecType.VIDEO);
                                    } else {
                                        codec = new Codec(CodecType.AUDIO);
                                    }
                                    codec.setCodecId(eCodec.getAttribute("codecId"));
                                    codec.setCodecIdHint(eCodec.getAttribute("codecIdHint"));
                                    codec.setCodecFormat(eCodec.getAttribute("format"));
                                    codec.setCodecFormatProfile(eCodec.getAttribute("formatProfile"));
                                    codec.setCodecFormatVersion(eCodec.getAttribute("formatVersion"));
                                    codec.setCodecLanguage(eCodec.getAttribute(LANGUAGE));
                                    codec.setCodecBitRate(eCodec.getAttribute("bitrate"));
                                    String tmpValue = eCodec.getAttribute("channels");
                                    if (StringUtils.isNotBlank(tmpValue)) {
                                        codec.setCodecChannels(
                                                Integer.parseInt(eCodec.getAttribute("channels")));
                                    }
                                    codec.setCodec(eCodec.getTextContent().trim());

                                    tmpValue = eCodec.getAttribute(SOURCE);
                                    if (StringTools.isValidString(tmpValue)) {
                                        codec.setCodecSource(CodecSource.fromString(tmpValue));
                                    } else {
                                        codec.setCodecSource(CodecSource.UNKNOWN);
                                    }

                                    movie.addCodec(codec);
                                }
                            } // END of codec information for audio/video
                        }
                    } // END of audio/video codec
                } // END of codecs loop
            } // END of codecs

            // get the resolution
            parseOverridableResolution(movie, eMovie);

            // get the video source
            parseOverridableVideoSource(movie, eMovie);

            // get the video output
            parseOverridableVideoOutput(movie, eMovie);

            // get aspect ratio
            parseOverridableAspectRatio(movie, eMovie);

            // get frames per second
            parseOverridableFramesPerSecond(movie, eMovie);

            // Get navigation info
            movie.setFirst(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "first")));
            movie.setPrevious(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "previous")));
            movie.setNext(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "next")));
            movie.setLast(HTMLTools.decodeUrl(DOMHelper.getValueFromElement(eMovie, "last")));

            // Get the library description, if it's not been set elsewhere (e.g. scanner)
            String tempLibraryDescription = DOMHelper.getValueFromElement(eMovie, "libraryDescription");
            if (StringTools.isNotValidString(movie.getLibraryDescription())) {
                movie.setLibraryDescription(tempLibraryDescription);
            } else if (!movie.getLibraryDescription().equals(tempLibraryDescription)) {
                // The current description is different to the one in the XML
                LOG.debug("Different library description! Setting dirty INFO");
                forceDirtyFlag = Boolean.TRUE;
            }

            // Get prebuf
            movie.setPrebuf(Long.parseLong(DOMHelper.getValueFromElement(eMovie, "prebuf")));

            // Issue 1901: Awards
            nlElements = eMovie.getElementsByTagName("awards");
            if (nlElements.getLength() > 0) {
                nlElements = nlElements.item(0).getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element eAwardEvent = (Element) nElements;
                        AwardEvent awardEvent = new AwardEvent();
                        awardEvent.setName(eAwardEvent.getAttribute(NAME));

                        Node nAward;
                        for (int loopAwards = 0; loopAwards < eAwardEvent.getChildNodes()
                                .getLength(); loopAwards++) {
                            nAward = eAwardEvent.getChildNodes().item(loopAwards);
                            if (nAward.getNodeType() == Node.ELEMENT_NODE) {
                                Element eAward = (Element) nAward;
                                Award award = new Award();

                                award.setName(eAward.getTextContent());
                                award.setNominated(Integer.parseInt(eAward.getAttribute("nominated")));
                                award.setWon(Integer.parseInt(eAward.getAttribute(WON)));
                                award.setYear(Integer.parseInt(eAward.getAttribute(YEAR)));
                                String tmpAward = eAward.getAttribute("wons");
                                if (StringTools.isValidString(tmpAward)) {
                                    award.setWons(Arrays.asList(tmpAward.split(Movie.SPACE_SLASH_SPACE)));
                                }
                                tmpAward = eAward.getAttribute("nominations");
                                if (StringTools.isValidString(tmpAward)) {
                                    award.setNominations(
                                            Arrays.asList(tmpAward.split(Movie.SPACE_SLASH_SPACE)));
                                }

                                awardEvent.addAward(award);
                            }
                        } // End of Awards

                        movie.addAward(awardEvent);
                    }
                }
            } // End of AwardEvents

            // Issue 1897: Cast enhancement
            nlElements = eMovie.getElementsByTagName("people");
            if (nlElements.getLength() > 0) {
                nlElements = nlElements.item(0).getChildNodes();

                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element ePerson = (Element) nElements;
                        Filmography person = new Filmography();

                        person.setCastId(ePerson.getAttribute("cast_id"));
                        person.setCharacter(ePerson.getAttribute(CHARACTER));
                        person.setDepartment(ePerson.getAttribute(DEPARTMENT));
                        person.setDoublage(ePerson.getAttribute("doublage"));
                        person.setId(ePerson.getAttribute("id"));
                        person.setJob(ePerson.getAttribute(JOB));
                        person.setName(ePerson.getAttribute(NAME));
                        person.setOrder(ePerson.getAttribute(ORDER));
                        person.setTitle(ePerson.getAttribute(TITLE));
                        person.setUrl(ePerson.getAttribute(URL));
                        person.setPhotoFilename(ePerson.getAttribute("photoFile"));
                        person.setFilename(ePerson.getTextContent());

                        // Get any "id_???" values
                        for (int loopAttr = 0; loopAttr < ePerson.getAttributes().getLength(); loopAttr++) {
                            Node nPersonAttr = ePerson.getAttributes().item(loopAttr);
                            if (nPersonAttr.getNodeName().startsWith(ID)) {
                                String name = nPersonAttr.getNodeName().replace(ID, "");
                                person.setId(name, nPersonAttr.getNodeValue());
                            }
                        }

                        String source = ePerson.getAttribute(SOURCE);
                        if (StringTools.isValidString(source)) {
                            person.setSource(source);
                            if (person.getDepartment().equalsIgnoreCase(Filmography.DEPT_DIRECTING)) {
                                movie.setOverrideSource(OverrideFlag.PEOPLE_DIRECTORS, source);
                            } else if (person.getDepartment().equalsIgnoreCase(Filmography.DEPT_WRITING)) {
                                movie.setOverrideSource(OverrideFlag.PEOPLE_WRITERS, source);
                            } else if (person.getDepartment().equalsIgnoreCase(Filmography.DEPT_ACTORS)) {
                                movie.setOverrideSource(OverrideFlag.PEOPLE_ACTORS, source);
                            }
                        } else {
                            person.setSource(Movie.UNKNOWN);
                        }
                        movie.addPerson(person);
                    }
                }
            } // End of Cast

            // Issue 2012: Financial information about movie
            nlElements = eMovie.getElementsByTagName("business");
            for (int looper = 0; looper < nlElements.getLength(); looper++) {
                nElements = nlElements.item(looper);
                if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                    Element eBusiness = (Element) nElements;
                    movie.setBudget(eBusiness.getAttribute("budget"));

                    Node nCountry;
                    for (int loopBus = 0; loopBus < eBusiness.getChildNodes().getLength(); loopBus++) {
                        nCountry = eBusiness.getChildNodes().item(loopBus);
                        if (nCountry.getNodeType() == Node.ELEMENT_NODE) {
                            Element eCountry = (Element) nCountry;
                            if ("gross".equalsIgnoreCase(eCountry.getNodeName())) {
                                movie.setGross(eCountry.getAttribute(COUNTRY), eCountry.getTextContent());
                            } else if ("openweek".equalsIgnoreCase(eCountry.getNodeName())) {
                                movie.setOpenWeek(eCountry.getAttribute(COUNTRY), eCountry.getTextContent());
                            }
                        }
                    } // End of budget info
                }
            } // End of business info

            // Issue 2013: Add trivia
            if (ENABLE_TRIVIA) {
                nlElements = eMovie.getElementsByTagName("trivia");
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    movie.addDidYouKnow(nElements.getTextContent());
                }
            } // End of trivia info

            // Get the file list
            nlElements = eMovie.getElementsByTagName("files");
            if (nlElements.getLength() > 0) {
                nlElements = nlElements.item(0).getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element eFile = (Element) nElements;
                        MovieFile movieFile = new MovieFile();

                        try {
                            File mfFile = new File(DOMHelper.getValueFromElement(eFile, "fileLocation"));
                            // Check to see if the file exists, or we are preserving the jukebox
                            if (mfFile.exists() || MovieJukebox.isJukeboxPreserve()) {
                                // Save the file to the MovieFile
                                movieFile.setFile(mfFile);
                            } else {
                                // We can't find this file anymore, so skip it.
                                LOG.debug(
                                        "Missing video file in the XML file ({}), it may have been moved or no longer exist.",
                                        mfFile.getName());
                                continue;
                            }
                        } catch (Exception ignore) {
                            // If there is an error creating the file then don't save anything
                            LOG.debug("Failed parsing file {}", xmlFile.getName());
                            continue;
                        }

                        String attr = eFile.getAttribute(TITLE);
                        if (StringTools.isValidString(attr)) {
                            movieFile.setTitle(attr);
                        }

                        attr = eFile.getAttribute(SEASON);
                        if (StringUtils.isNumeric(attr)) {
                            movieFile.setSeason(Integer.parseInt(attr));
                        }

                        attr = eFile.getAttribute("firstPart");
                        if (StringUtils.isNumeric(attr)) {
                            movieFile.setFirstPart(Integer.parseInt(attr));
                        }

                        attr = eFile.getAttribute("lastPart");
                        if (StringUtils.isNumeric(attr)) {
                            movieFile.setLastPart(Integer.parseInt(attr));
                        }

                        attr = eFile.getAttribute("subtitlesExchange");
                        if (StringTools.isValidString(attr)) {
                            movieFile.setSubtitlesExchange(attr.equalsIgnoreCase(YES));
                        }

                        movieFile.setFilename(DOMHelper.getValueFromElement(eFile, "fileURL"));

                        if (DOMHelper.getValueFromElement(eFile, "fileArchiveName") != null) {
                            movieFile.setArchiveName(DOMHelper.getValueFromElement(eFile, "fileArchiveName"));
                        }

                        // We need to get the part from the fileTitle
                        NodeList nlFileParts = eFile.getElementsByTagName("fileTitle");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    String part = eFileParts.getAttribute(PART);
                                    String source = eFileParts.getAttribute(SOURCE);
                                    if (StringUtils.isNumeric(part)) {
                                        movieFile.setTitle(NumberUtils.toInt(part, 0),
                                                eFileParts.getTextContent(), source);
                                    } else {
                                        movieFile.setTitle(eFileParts.getTextContent(), source);
                                    }
                                }
                            }
                        }

                        // Get the airs info
                        nlFileParts = eFile.getElementsByTagName("airsInfo");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    int part = NumberUtils.toInt(eFileParts.getAttribute(PART), 1);

                                    movieFile.setAirsAfterSeason(part, eFileParts.getAttribute("afterSeason"));
                                    movieFile.setAirsBeforeEpisode(part,
                                            eFileParts.getAttribute("beforeEpisode"));
                                    movieFile.setAirsBeforeSeason(part,
                                            eFileParts.getAttribute("beforeSeason"));
                                }
                            }
                        }

                        // Get first aired information
                        nlFileParts = eFile.getElementsByTagName("firstAired");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    int part = NumberUtils.toInt(eFileParts.getAttribute(PART), 1);
                                    String source = eFileParts.getAttribute(SOURCE);
                                    movieFile.setFirstAired(part, eFileParts.getTextContent(), source);
                                }
                            }
                        }

                        // get the file plot
                        nlFileParts = eFile.getElementsByTagName("filePlot");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    int part = NumberUtils.toInt(eFileParts.getAttribute(PART), 1);
                                    String source = eFileParts.getAttribute(SOURCE);
                                    movieFile.setPlot(part, eFileParts.getTextContent(), source, Boolean.TRUE);
                                }
                            }
                        }

                        // get the file rating
                        nlFileParts = eFile.getElementsByTagName("fileRating");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    int part = NumberUtils.toInt(eFileParts.getAttribute(PART), 1);
                                    String source = eFileParts.getAttribute(SOURCE);
                                    movieFile.setRating(part, eFileParts.getTextContent(), source);
                                }
                            }
                        }

                        // get the file image url
                        nlFileParts = eFile.getElementsByTagName("fileImageURL");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    int part = NumberUtils.toInt(eFileParts.getAttribute(PART), 1);
                                    movieFile.setVideoImageURL(part,
                                            HTMLTools.decodeUrl(eFileParts.getTextContent()));
                                }
                            }
                        }

                        // get the file image filename
                        nlFileParts = eFile.getElementsByTagName("fileImageFile");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    int part = NumberUtils.toInt(eFileParts.getAttribute(PART), 1);
                                    movieFile.setVideoImageFilename(part,
                                            HTMLTools.decodeUrl(eFileParts.getTextContent()));
                                }
                            }
                        }

                        // get the file IDs
                        nlFileParts = eFile.getElementsByTagName("fileId");
                        if (nlFileParts.getLength() > 0) {
                            for (int looperFile = 0; looperFile < nlFileParts.getLength(); looperFile++) {
                                Node nFileParts = nlFileParts.item(looperFile);
                                if (nFileParts.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eFileParts = (Element) nFileParts;
                                    int part = NumberUtils.toInt(eFileParts.getAttribute(PART), 1);
                                    String source = eFileParts.getAttribute(SOURCE);
                                    movieFile.setId(part, source, eFileParts.getTextContent());
                                }
                            }
                        }

                        NodeList nlAttachments = eMovie.getElementsByTagName("attachments");
                        if (nlAttachments.getLength() > 0) {
                            nlAttachments = nlAttachments.item(0).getChildNodes();
                            for (int looperAtt = 0; looperAtt < nlAttachments.getLength(); looperAtt++) {
                                Node nAttachment = nlAttachments.item(looperAtt);
                                if (nAttachment.getNodeType() == Node.ELEMENT_NODE) {
                                    Element eAttachment = (Element) nAttachment;
                                    Attachment attachment = new Attachment();
                                    attachment.setType(
                                            AttachmentType.fromString(eAttachment.getAttribute("type")));
                                    attachment.setAttachmentId(Integer.parseInt(
                                            DOMHelper.getValueFromElement(eAttachment, "attachmentId")));
                                    attachment.setContentType(ContentType.fromString(
                                            DOMHelper.getValueFromElement(eAttachment, "contentType")));
                                    attachment.setMimeType(
                                            DOMHelper.getValueFromElement(eAttachment, "mimeType"));
                                    attachment.setPart(Integer
                                            .parseInt(DOMHelper.getValueFromElement(eAttachment, "part")));
                                    attachment.setSourceFile(movieFile.getFile());
                                    movieFile.addAttachment(attachment);
                                }
                            }
                        }

                        // Parse watched 
                        String watchedDateString = DOMHelper.getValueFromElement(eFile, "watchedDate");
                        final long watchedDate;
                        if (StringTools.isNotValidString(watchedDateString)) {
                            watchedDate = 0;
                        } else {
                            // strip milliseconds
                            Calendar cal = Calendar.getInstance();
                            cal.setTimeInMillis(DateTime.parse(watchedDateString).toMillis());
                            cal.set(Calendar.MILLISECOND, 0);
                            watchedDate = cal.getTimeInMillis();
                        }
                        final boolean watched = Boolean.parseBoolean(eFile.getAttribute("watched"));
                        movieFile.setWatched(watched, watchedDate);

                        // This is not a new file
                        movieFile.setNewFile(Boolean.FALSE);

                        // Add the movie file to the movie
                        movie.addMovieFile(movieFile);
                    }
                }
            } // END of files

            // Get the extra list
            nlElements = eMovie.getElementsByTagName("extras");
            if (nlElements.getLength() > 0) {
                nlElements = nlElements.item(0).getChildNodes();
                for (int looper = 0; looper < nlElements.getLength(); looper++) {
                    nElements = nlElements.item(looper);
                    if (nElements.getNodeType() == Node.ELEMENT_NODE) {
                        Element eExtra = (Element) nElements;

                        String extraTitle = eExtra.getAttribute(TITLE);
                        String extraFilename = eExtra.getTextContent();

                        if (!extraTitle.isEmpty() && !extraFilename.isEmpty()) {
                            boolean exist = Boolean.FALSE;
                            if (extraFilename.startsWith("http:")) {
                                // This is a URL from a NFO file
                                ExtraFile ef = new ExtraFile();
                                ef.setNewFile(Boolean.FALSE);
                                ef.setTitle(extraTitle);
                                ef.setFilename(extraFilename);
                                movie.addExtraFile(ef, Boolean.FALSE); // Add to the movie, but it's not dirty
                                exist = Boolean.TRUE;
                            } else {
                                // Check for existing files
                                for (ExtraFile ef : movie.getExtraFiles()) {
                                    // Check if the movie has already the extra file
                                    if (ef.getFilename().equals(extraFilename)) {
                                        exist = Boolean.TRUE;
                                        // the extra file is old
                                        ef.setNewFile(Boolean.FALSE);
                                        break;
                                    }
                                }
                            }

                            if (!exist) {
                                // the extra file has been deleted so force the dirty flag
                                forceDirtyFlag = Boolean.TRUE;
                            }
                        }
                    }
                }
            } // END of extras

        } // End of ELEMENT_NODE
    } // End of Movie Loop

    // This is a new movie, so clear the current dirty flags
    movie.clearDirty();
    movie.setDirty(DirtyFlag.INFO, forceDirtyFlag || movie.hasNewMovieFiles() || movie.hasNewExtraFiles());

    return Boolean.TRUE;
}

From source file:com.sat.vcse.automation.utils.http.HttpClient.java

/**
 * Creates HttpHost from given targetURL. Depending on whether port is explicitly present or no
 * @param url : the target url// w w w  .  j  a v  a 2 s.  co m
 * @return HttpHost object representing the service host and port
 */
private HttpHost getTargetHost(String url) {
    //Sample value of URL -->http://123.456.177.106:2013/service/xyxz
    final String tempURL = url.substring(url.indexOf("//") + 2); //tempURL =10.90.177.106:2013/service/xyxz
    int index = tempURL.indexOf("/");// use this to extract host and port

    //Get the host and port -->10.90.177.106:2013
    final String onlyHostPort = tempURL.substring(0, index);
    //split host and port
    final String[] hostPort = onlyHostPort.split(":");
    HttpHost targetHost = null;
    if (hostPort.length == 1) { //Only host is available, port is  explicitly unavailable
        targetHost = new HttpHost(hostPort[0]);
    } else if (StringUtils.isNumeric(hostPort[1])) { //host, port both available
        targetHost = new HttpHost(hostPort[0], Integer.valueOf(hostPort[1]));
    } else {
        throw new CoreRuntimeException("Please check the url; port number seems to be wrong !");
    }

    return targetHost;

}