Example usage for java.util Hashtable get

List of usage examples for java.util Hashtable get

Introduction

In this page you can find the example usage for java.util Hashtable get.

Prototype

@SuppressWarnings("unchecked")
public synchronized V get(Object key) 

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:edu.ku.brc.specify.utilapps.RegProcessor.java

/**
 * @param inFile// w  w  w.  j  a  v a  2s. co  m
 */
public void processSQL() {
    String sql = "SELECT r.RegisterID, r.RegNumber, ri.Name, ri.Value, ri.CountAmt, r.TimestampCreated, r.IP"
            + " FROM register r INNER JOIN registeritem ri ON r.RegisterID = ri.RegisterID WHERE r.TimestampCreated > '2009-04-12' ORDER BY r.RegNumber";
    System.err.println(sql);
    //Connection connection = DBConnection.getInstance().getConnection();
    try {
        stmt = DBConnection.getInstance().getConnection().createStatement();
        ResultSet rs = stmt.executeQuery(sql);
        int prevId = Integer.MAX_VALUE;
        RegProcEntry currEntry = null;
        while (rs.next()) {
            int id = rs.getInt(1);
            if (id != prevId) {
                if (currEntry != null) {
                    String regType = currEntry.get("reg_type");
                    if (regType != null) {
                        Hashtable<String, RegProcEntry> entryHash = typeHash.get(regType);
                        if (entryHash == null) {
                            entryHash = new Hashtable<String, RegProcEntry>();
                            typeHash.put(regType, entryHash);
                        }
                        currEntry.put("reg_number", currEntry.getId());
                        currEntry.setType(currEntry.get("reg_type"));

                        if (entryHash.get(currEntry.getId()) == null) {
                            entryHash.put(currEntry.getId(), currEntry);
                        } else {
                            System.err.println("Already there: " + currEntry.getId());
                        }
                    } else {
                        System.err.println("1Skipping: " + rs.getString(2));
                    }
                }

                String regNumber = rs.getString(2);
                String ip = rs.getString(7);
                currEntry = regNumHash.get(regNumber);
                if (currEntry == null) {
                    if (ip != null) {
                        currEntry = new RegProcEntry();
                        regNumHash.put(regNumber, currEntry);
                        currEntry.setId(regNumber);
                        currEntry.setTimestampCreated(rs.getTimestamp(6));
                        currEntry.put("ip", ip);

                    } else {
                        System.err.println("IP is null for " + regNumber);
                        ip = "N/A";
                    }

                } else {
                    System.err.println("Already " + regNumber);
                }

                prevId = id;

            } else if (prevId == Integer.MAX_VALUE) {
                prevId = id;
            }

            String value = rs.getString(4);
            if (value == null) {
                value = rs.getString(5);
            }

            String propName = rs.getString(3);
            if (currEntry != null && value != null && propName != null) {
                currEntry.put(propName, value);
            }
        }
        rs.close();

        Hashtable<String, RegProcEntry> checkHash = new Hashtable<String, RegProcEntry>();
        Hashtable<String, RegProcEntry> instHash = typeHash.get("Institution");

        for (RegProcEntry entry : new Vector<RegProcEntry>(regNumHash.values())) {
            entry.setName(null);
            String ip = entry.get("ip");
            if (ip == null || ip.startsWith("129.") || ip.startsWith("24.")) {
                System.out.println("Removing ip: " + ip);
                instHash.remove(entry.getId());
                regNumHash.remove(entry.getId());

            } else {
                RegProcEntry e = checkHash.get(ip);
                if (e == null) {
                    checkHash.put(ip, entry);
                } else {
                    instHash.remove(e.getId());
                    regNumHash.remove(e.getId());
                    checkHash.put(ip, entry);
                    System.out.println("Compressing ip: " + ip);
                }
            }
        }

        buildTree();

    } catch (SQLException ex) {
        ex.printStackTrace();

    } finally {
        if (stmt != null) {
            try {
                stmt.close();
            } catch (Exception ex) {
            }
        }
    }
}

From source file:edu.ku.brc.af.ui.forms.persist.ViewLoader.java

/**
 * @param rows/*from  w w  w. j  a  va 2s  .c  o  m*/
 * @param tableInfo
 */
protected static void fixLabels(final String name, final List<FormRowIFace> rows, final DBTableInfo tableInfo) {
    if (tableInfo == null) {
        return;
    }

    Hashtable<String, String> fldIdMap = new Hashtable<String, String>();
    for (FormRowIFace row : rows) {
        for (FormCellIFace cell : row.getCells()) {
            if (cell.getType() == FormCellIFace.CellType.field
                    || cell.getType() == FormCellIFace.CellType.subview) {
                fldIdMap.put(cell.getIdent(), cell.getName());
            } /* else
              {
              System.err.println("Skipping ["+cell.getIdent()+"] " + cell.getType());
              }*/
        }
    }

    for (FormRowIFace row : rows) {
        for (FormCellIFace cell : row.getCells()) {
            if (cell.getType() == FormCellIFace.CellType.label) {
                FormCellLabelIFace lblCell = (FormCellLabelIFace) cell;
                String label = lblCell.getLabel();
                if (label.length() == 0 || label.equals("##")) {
                    String idFor = lblCell.getLabelFor();
                    if (StringUtils.isNotEmpty(idFor)) {
                        String fieldName = fldIdMap.get(idFor);
                        if (StringUtils.isNotEmpty(fieldName)) {
                            if (!fieldName.equals("this")) {
                                //FormCellFieldIFace fcf = get
                                lblCell.setLabel(getTitleFromFieldName(fieldName, tableInfo));
                            }

                        } else {
                            String msg = "Setting Label - Form control with id[" + idFor
                                    + "] is not in ViewDef or Panel [" + name + "] in ViewSet ["
                                    + instance.viewSetName + "]";
                            log.error(msg);
                            FormDevHelper.appendFormDevError(msg);
                        }
                    }
                }
            } else if (cell.getType() == FormCellIFace.CellType.field && cell instanceof FormCellFieldIFace
                    && ((((FormCellFieldIFace) cell).getUiType() == FormCellFieldIFace.FieldType.checkbox)
                            || (((FormCellFieldIFace) cell)
                                    .getUiType() == FormCellFieldIFace.FieldType.tristate))) {
                FormCellFieldIFace fcf = (FormCellFieldIFace) cell;
                if (fcf.getLabel().equals("##")) {
                    fcf.setLabel(getTitleFromFieldName(cell.getName(), tableInfo));
                }
            }

        }
    }
}

From source file:hd.controller.AddImageToIdeaBookServlet.java

/**
 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
 * methods./* w w w  .  j  a  v a2  s  .c o m*/
 *
 * @param request servlet request
 * @param response servlet response
 * @throws ServletException if a servlet-specific error occurs
 * @throws IOException if an I/O error occurs
 */
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    response.setContentType("text/html; charset=UTF-8");

    PrintWriter out = response.getWriter();
    try {
        boolean isMultipart = ServletFileUpload.isMultipartContent(request);
        if (!isMultipart) { //to do

        } else {
            FileItemFactory factory = new DiskFileItemFactory();
            ServletFileUpload upload = new ServletFileUpload(factory);
            List items = null;
            try {
                items = upload.parseRequest(request);

            } catch (FileUploadException e) {
                e.printStackTrace();
            }
            Iterator iter = items.iterator();
            Hashtable params = new Hashtable();

            String fileName = null;
            while (iter.hasNext()) {
                FileItem item = (FileItem) iter.next();
                if (item.isFormField()) {
                    params.put(item.getFieldName(), item.getString("UTF-8"));

                } else if (!item.isFormField()) {
                    try {
                        long time = System.currentTimeMillis();
                        String itemName = item.getName();
                        fileName = time + itemName.substring(itemName.lastIndexOf("\\") + 1);

                        String RealPath = getServletContext().getRealPath("/") + "images\\" + fileName;

                        File savedFile = new File(RealPath);
                        item.write(savedFile);

                        String localPath = "D:\\Project\\TestHouseDecor-Merge\\web\\images\\" + fileName;
                        //                            savedFile = new File(localPath);
                        //                            item.write(savedFile);

                    } catch (Exception e) {
                        e.printStackTrace();
                    }

                }
            }

            String ideaBookIdTemp = (String) params.get("txtIdeabookId");
            int ideaBookId = Integer.parseInt(ideaBookIdTemp);
            IdeaBookDAO ideabookDao = new IdeaBookDAO();

            String tilte = (String) params.get("newGalleryName");

            String description = (String) params.get("GalleryDescription");
            String url = "images/" + fileName;

            IdeaBookPhotoDAO photoDAO = new IdeaBookPhotoDAO();
            IdeaBookPhoto ideaBookPhoto = photoDAO.insertIdeaBookPhoto(tilte, description, url, ideaBookId);

            HDSystem system = new HDSystem();
            system.setNotificationIdeaBook(request);
            response.sendRedirect("MyIdeaBookDetailServlet?txtIdeabookId=" + ideaBookId);

        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        out.close();
    }
}

From source file:at.ac.tuwien.auto.iotsys.gateway.connectors.knx.KNXDeviceLoaderETSImpl.java

private void parseTopologyView(HierarchicalConfiguration areaConfig, Obj parent, Network n,
        ObjectBroker objectBroker, Hashtable<String, EntityImpl> entityById,
        Hashtable<String, DatapointImpl> datapointById, Hashtable<String, String> resourceById) {
    for (int areaIdx = 0; areaIdx < sizeOfConfiguration(areaConfig.getProperty("area.[@id]")); areaIdx++) {
        String areaId = areaConfig.getString("area(" + areaIdx + ").[@id]");
        String areaName = arrayToString(areaConfig.getStringArray("area(" + areaIdx + ").[@name]"));
        String areaDescription = arrayToString(
                areaConfig.getStringArray("area(" + areaIdx + ").[@description]"));
        String areaMediaTypeId = areaConfig.getString("area(" + areaIdx + ").[@mediaTypeId]");
        long areaAddress = areaConfig.getLong("area(" + areaIdx + ").[@address]");

        String areaMediaType = null;
        if (areaMediaTypeId != null) {
            areaMediaType = resourceById.get(areaMediaTypeId);
        }/*from  w w  w  .ja  va  2  s  . c  om*/

        AreaImpl area = new AreaImpl(areaId, areaName, areaDescription, areaAddress, areaMediaType);

        // add part to parent part
        if (parent instanceof ViewTopologyImpl)
            ((ViewTopologyImpl) parent).addArea(area);
        else if (parent instanceof DomainImpl)
            ((AreaImpl) parent).addArea(area);
        else
            parent.add(area);

        objectBroker.addObj(area, true);

        // add instances to part
        HierarchicalConfiguration concreteArea = areaConfig.configurationAt("area(" + areaIdx + ")");

        for (int instanceIdx = 0; instanceIdx < sizeOfConfiguration(
                concreteArea.getProperty("instance.[@id]")); instanceIdx++) {
            String instanceId = concreteArea.getString("instance(" + instanceIdx + ").[@id]");
            long address = concreteArea.getLong("instance(" + instanceIdx + ").[@address]");

            Obj addInstance = area.addInstance(entityById.get(instanceId), address);
            objectBroker.addObj(addInstance, true);

        }

        // recursively add more domains
        parseTopologyView(concreteArea, area, n, objectBroker, entityById, datapointById, resourceById);
    }
}

From source file:com.krawler.spring.crm.common.documentController.java

public ModelAndView downloadAttachment(HttpServletRequest request, HttpServletResponse response)
        throws ServletException {
    JSONObject myjobj = new JSONObject();
    KwlReturnObject kmsg = null;/*w  ww .  ja v  a2 s.  c  o  m*/
    try {
        String url = request.getParameter("url");
        url = StringUtil.checkForNull(url);
        kmsg = crmDocumentDAOObj.downloadDocument(url);
        Hashtable ht = getDocumentDownloadHash(kmsg.getEntityList());
        String src = storageHandlerImplObj.GetDocStorePath();
        if (request.getParameter("mailattch") != null) {
            if (Boolean.parseBoolean(request.getParameter("mailattch"))) {
                src = storageHandlerImplObj.GetEmailUploadFilePath();
                src = src + url;
            } else
                src = src + ht.get("svnname");
        } else {
            src = src + ht.get("userid").toString() + "/" + ht.get("svnname");
        }

        File fp = new File(src);
        byte[] buff = new byte[(int) fp.length()];
        FileInputStream fis = new FileInputStream(fp);
        int read = fis.read(buff);
        javax.activation.FileTypeMap mmap = new javax.activation.MimetypesFileTypeMap();
        response.setContentType(mmap.getContentType(src));
        response.setContentLength((int) fp.length());
        response.setHeader("Content-Disposition",
                request.getParameter("dtype") + "; filename=\"" + request.getParameter("fname") + "\";");
        response.getOutputStream().write(buff);
        response.getOutputStream().flush();
        response.getOutputStream().close();
        myjobj.put("success", true);
    } catch (Exception e) {
        logger.warn(e.getMessage(), e);
    }
    return new ModelAndView("jsonView", "model", myjobj.toString());
}

From source file:com.autentia.tnt.manager.billing.BillManager.java

public List<BillBreakDown> getAllBitacoreBreakDowns(Date start, Date end, Project project) {

    final List<BillBreakDown> desgloses = new ArrayList<BillBreakDown>();

    ActivityDAO activityDAO = ActivityDAO.getDefault();
    ActivitySearch actSearch = new ActivitySearch();
    actSearch.setBillable(new Boolean(true));
    actSearch.setStartStartDate(start);/*from   www.  ja v a2 s.c o  m*/
    actSearch.setEndStartDate(end);

    List<Activity> actividadesTotal = new ArrayList<Activity>();
    Hashtable user_roles = new Hashtable();

    ProjectRoleDAO projectRoleDAO = ProjectRoleDAO.getDefault();
    ProjectRoleSearch prjRolSearch = new ProjectRoleSearch();
    prjRolSearch.setProject(project);
    List<ProjectRole> roles = projectRoleDAO.search(prjRolSearch, new SortCriteria("id", false));
    for (ProjectRole proyRole : roles) {
        actSearch.setRole(proyRole);
        List<Activity> actividades = activityDAO.search(actSearch, new SortCriteria("startDate", false));
        actividadesTotal.addAll(actividades);
    }

    for (Activity act : actividadesTotal) {
        String key = act.getRole().getId().toString() + act.getUser().getId().toString();

        if (!user_roles.containsKey(key)) {
            Hashtable value = new Hashtable();
            value.put("ROLE", act.getRole());
            value.put("USER", act.getUser());
            user_roles.put(key, value);
        }
    }

    Enumeration en = user_roles.keys();

    while (en.hasMoreElements()) {
        String key = (String) en.nextElement();
        Hashtable pair = (Hashtable) user_roles.get(key);
        actSearch.setBillable(new Boolean(true));
        actSearch.setStartStartDate(start);
        actSearch.setEndStartDate(end);

        ProjectRole pR = (ProjectRole) pair.get("ROLE");
        User u = (User) pair.get("USER");
        actSearch.setRole(pR);
        actSearch.setUser(u);
        List<Activity> actividadesUsuarioRol = activityDAO.search(actSearch,
                new SortCriteria("startDate", false));

        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Imputaciones (usuario - rol): " + u.getName() + " - " + pR.getName());
        brd.setAmount(pR.getCostPerHour());

        IvaApplicator.applyIvaToTaxableObject(start, brd);

        BigDecimal unitsTotal = new BigDecimal(0);
        for (Activity act : actividadesUsuarioRol) {
            BigDecimal unitsActual = new BigDecimal(act.getDuration());
            unitsActual = unitsActual.divide(new BigDecimal(60), 2, RoundingMode.HALF_UP);
            unitsTotal = unitsTotal.add(unitsActual);
        }
        brd.setUnits(unitsTotal);
        brd.setSelected(true);
        desgloses.add(brd);
    }

    ProjectCostDAO prjCostDAO = ProjectCostDAO.getDefault();
    ProjectCostSearch prjCostSearch = new ProjectCostSearch();
    prjCostSearch.setProject(project);
    List<ProjectCost> costes = prjCostDAO.search(prjCostSearch, new SortCriteria("id", false));
    for (ProjectCost proyCost : costes) {
        BillBreakDown brd = new BillBreakDown();
        brd.setConcept("Coste: " + proyCost.getName());
        brd.setUnits(new BigDecimal(1));
        brd.setAmount(proyCost.getCost());

        IvaApplicator.applyIvaToTaxableObject(start, brd);

        brd.setSelected(true);
        desgloses.add(brd);
    }

    return desgloses;

}

From source file:com.cloudbase.CBHelper.java

private Hashtable prepareStandardParams(Hashtable additionalParams) {
    Hashtable post = new Hashtable();
    post.put("app_uniq", this.appSecret);
    post.put("app_pwd", this.password);
    post.put("device_uniq", this.deviceUniqueIdentifier);

    // additional parameters are used for the CloudFunction and Applet APIs
    if (additionalParams != null) {
        Enumeration keys = additionalParams.keys();
        //for (String curKey : keys)
        while (keys.hasMoreElements()) {
            String curKey = (String) keys.nextElement();
            post.put(curKey, additionalParams.get(curKey));
        }/*  w ww . j a  va 2 s.  c  om*/
    }

    if (this.userAuthentication) {
        post.put("cb_auth_user", this.authUsername);
        post.put("cb_auth_password", this.authPassword);
    }

    if (this.useLocation && this.currentLocation != null) {
        JSONObject locData = new JSONObject();
        try {
            locData.put("lat", Double.toString(this.currentLocation.getQualifiedCoordinates().getLatitude()));
            locData.put("lng", Double.toString(this.currentLocation.getQualifiedCoordinates().getLongitude()));
            locData.put("alt", Double.toString(this.currentLocation.getQualifiedCoordinates().getAltitude()));
        } catch (JSONException e) {
            e.printStackTrace();
        }

        post.put("location_data", locData.toString());
    }

    return post;
}

From source file:net.dian1.player.api.impl.JamendoGet2ApiImpl.java

private Playlist createPlaylist(Music[] aMusics, Album[] aAlbums, int[] aOrderBy)
        throws JSONException, WSError {
    if (aAlbums.length != aMusics.length)
        aAlbums = null;//from   w w w  .ja v a2s .  c o  m
    Playlist playlist = new Playlist();
    Hashtable<Integer, PlaylistEntry> bufferForOredr = new Hashtable<Integer, PlaylistEntry>();

    for (int i = 0; i < aMusics.length; i++) {
        PlaylistEntry playlistEntry = new PlaylistEntry();
        Album album;
        if (aAlbums != null) {
            album = aAlbums[i];
            playlistEntry.setAlbum(album);
        } else {
            album = getAlbumByTrackId(aMusics[i].getId());
            if (album == null) {
                album = Album.emptyAlbum;
            }
            playlistEntry.setAlbum(album);
        }
        playlistEntry.setMusic(aMusics[i]);
        bufferForOredr.put(aMusics[i].getId(), playlistEntry);

        if (album != Album.emptyAlbum) {
            Log.i("jamendroid", aMusics[i].getName() + " by " + album.getArtistName());
        } else {
            Log.i("jamendroid", aMusics[i].getName() + " without album");
        }
    }
    for (int i = 0; i < aOrderBy.length; i++) {
        // Adding to playlist in correct order
        playlist.addPlaylistEntry(bufferForOredr.get(aOrderBy[i]));
    }
    return playlist;
}

From source file:com.teleca.jamendo.api.impl.JamendoGet2ApiImpl.java

private Playlist createPlaylist(Track[] aTracks, Album[] aAlbums, int[] aOrderBy)
        throws JSONException, WSError {
    if (aAlbums.length != aTracks.length)
        aAlbums = null;//from   w w w .j a v a  2s.  c  o m
    Playlist playlist = new Playlist();
    Hashtable<Integer, PlaylistEntry> bufferForOredr = new Hashtable<Integer, PlaylistEntry>();

    for (int i = 0; i < aTracks.length; i++) {
        PlaylistEntry playlistEntry = new PlaylistEntry();
        Album album;
        if (aAlbums != null) {
            album = aAlbums[i];
            playlistEntry.setAlbum(album);
        } else {
            album = getAlbumByTrackId(aTracks[i].getId());
            if (album == null) {
                album = Album.emptyAlbum;
            }
            playlistEntry.setAlbum(album);
        }
        playlistEntry.setTrack(aTracks[i]);
        bufferForOredr.put(aTracks[i].getId(), playlistEntry);

        if (album != Album.emptyAlbum) {
            Log.i("jamendroid", aTracks[i].getName() + " by " + album.getArtistName());
        } else {
            Log.i("jamendroid", aTracks[i].getName() + " without album");
        }
    }
    for (int i = 0; i < aOrderBy.length; i++) {
        // Adding to playlist in correct order
        playlist.addPlaylistEntry(bufferForOredr.get(aOrderBy[i]));
    }
    return playlist;
}

From source file:edu.ku.brc.af.ui.forms.persist.ViewLoader.java

/**
 * Creates the view.//from   w  w  w.j  av  a  2 s.  co  m
 * @param element the element to build the View from
 * @param altViewsViewDefName the hashtable to track the AltView's ViewDefName
 * @return the View
 * @throws Exception
 */
protected static ViewIFace createView(final Element element,
        final Hashtable<AltViewIFace, String> altViewsViewDefName) throws Exception {
    String name = element.attributeValue(NAME);
    String objTitle = getAttr(element, "objtitle", null);
    String className = element.attributeValue(CLASSNAME);
    String desc = getDesc(element);
    String businessRules = getAttr(element, "busrules", null);
    boolean isInternal = getAttr(element, "isinternal", true);

    DBTableInfo ti = DBTableIdMgr.getInstance().getByClassName(className);
    if (ti != null && StringUtils.isEmpty(objTitle)) {
        objTitle = ti.getTitle();
    }

    View view = new View(instance.viewSetName, name, objTitle, className,
            businessRules != null ? businessRules.trim() : null, getAttr(element, "usedefbusrule", true),
            isInternal, desc);

    // Later we should get this from a properties file.
    if (ti != null) {
        view.setTitle(ti.getTitle());
    }

    /*if (!isInternal)
    {
    System.err.println(StringUtils.replace(name, " ", "_")+"="+UIHelper.makeNamePretty(name));
    }*/

    Element altviews = (Element) element.selectSingleNode("altviews");
    if (altviews != null) {
        AltViewIFace defaultAltView = null;

        AltView.CreationMode defaultMode = AltView.parseMode(getAttr(altviews, "mode", ""),
                AltViewIFace.CreationMode.VIEW);
        String selectorName = altviews.attributeValue("selector");

        view.setDefaultMode(defaultMode);
        view.setSelectorName(selectorName);

        Hashtable<String, Boolean> nameCheckHash = new Hashtable<String, Boolean>();

        // iterate through child elements
        for (Iterator<?> i = altviews.elementIterator("altview"); i.hasNext();) {
            Element altElement = (Element) i.next();

            AltView.CreationMode mode = AltView.parseMode(getAttr(altElement, "mode", ""),
                    AltViewIFace.CreationMode.VIEW);

            String altName = altElement.attributeValue(NAME);
            String viewDefName = altElement.attributeValue("viewdef");
            String title = altElement.attributeValue(TITLE);

            boolean isValidated = getAttr(altElement, "validated", mode == AltViewIFace.CreationMode.EDIT);
            boolean isDefault = getAttr(altElement, "default", false);

            // Make sure we only have one default view
            if (defaultAltView != null && isDefault) {
                isDefault = false;
            }

            // Check to make sure all the AlViews have different names.
            Boolean nameExists = nameCheckHash.get(altName);
            if (nameExists == null) // no need to check the boolean
            {
                AltView altView = new AltView(view, altName, title, mode, isValidated, isDefault, null); // setting a null viewdef
                altViewsViewDefName.put(altView, viewDefName);

                if (StringUtils.isNotEmpty(selectorName)) {
                    altView.setSelectorName(selectorName);

                    String selectorValue = altElement.attributeValue("selector_value");
                    if (StringUtils.isNotEmpty(selectorValue)) {
                        altView.setSelectorValue(selectorValue);

                    } else {
                        FormDevHelper.appendFormDevError("Selector Value is missing for viewDefName["
                                + viewDefName + "] altName[" + altName + "]");
                    }
                }

                if (defaultAltView == null && isDefault) {
                    defaultAltView = altView;
                }

                view.addAltView(altView);
                nameCheckHash.put(altName, true);

            } else {
                log.error("The altView name[" + altName + "] already exists!");
            }
            nameCheckHash.clear(); // why not?
        }

        // No default Alt View was indicated, so choose the first one (if there is one)
        if (defaultAltView == null && view.getAltViews() != null && view.getAltViews().size() > 0) {
            view.getAltViews().get(0).setDefault(true);
        }
    }

    return view;
}