/** Add Mimetype to the MimetypeMap */ public void addMimetype(MimeType mimetype) { if (mimetype != null) // avoid null due to duplicates in database this.mimeTypeMap.put(mimetype.getName(), mimetype); }
/** Returns the preferred MIME type for the current user-agent */ public MimeType getPreferredType() { // Return the value that matches the preferredMimeType defined in the Client int prefMimeTypeId = this.client.getPreferredMimeTypeId(); MimeType mt = null; Iterator e = this.mimeTypeMap.values().iterator(); while (e.hasNext()) { mt = (MimeType) e.next(); if (mt.getMimetypeId() == prefMimeTypeId) return mt; } log.error("Could not find preferred Mime Type for " + prefMimeTypeId); // Should never reach this point. A preferred value needs to be set return null; }
public MimeType createMimeType(String mimeType) throws ClassNotFoundException { MimeType mimeTypeobj = null; if (mimeType != null) { //try to find it in space mimeTypeobj = this.getMimeType(mimeType); if (mimeTypeobj != null) return mimeTypeobj; } try { mimeTypeobj = (MimeType) beanFactory.getBean( this.mimeTypeBeanName, MimeType.class); mimeTypeobj.setName(mimeType); return mimeTypeobj; } catch (Exception e) { log.error("Failed to create capability instance for " + this.mimeTypeBeanName + " error : " + e.getLocalizedMessage()); throw new ClassNotFoundException("Spring failed to create the " + this.mimeTypeBeanName + " mimeType bean.", e); } }
/** * exstract the mime types anmd save in snapshot file * * @throws SerializerException */ private void exportMimeTypes(Refs refs, JSSnapshot snapshot, Map<String,Object> settings, Logger log) throws SerializerException { Iterator list = caps.getMimeTypes(); while (list.hasNext()) { try { MimeType _mt = (MimeType) list.next(); JSMimeType _jsM = new JSMimeType(); _jsM.setName(_mt.getName()); refs.mimeMap.put(_jsM.getName(), _jsM); refs.mimeMapInt.put(new Integer(_mt.getMimetypeId()), _jsM); snapshot.getMimeTypes().add(_jsM); } catch (Exception e) { throw new SerializerException( SerializerException.CREATE_SERIALIZED_OBJECT_FAILED .create(new String[] { "MimeType", e.getMessage()})); } } return; }
if (_mt.getMimetypeId() == 0) if (myPrefMimeType.equalsIgnoreCase(_mt.getName())) client.setPreferredMimeTypeId(_mt.getMimetypeId());
public void addMimetype(MimeType mimeType) { if (mimetypes == null) mimetypes = new ArrayList(); if (!mimetypes.contains(mimeType.getName())) { mimetypes.add(mimeType); } }
|| (mimeType.getMimetypeId() == 0))
/** Return true if this CapabilityMap supports the given MimeType */ public boolean supportsMimeType(MimeType mimeType) { Iterator<MimeType> mimetypes = mimeTypeMap.values().iterator(); while (mimetypes.hasNext()) { if (mimetypes.next().getName().equals(mimeType.getName())) { return true; } } return false; }
/** * Implements the equals operation so that 2 elements are equal if * all their member values are equal. * * * @param object to compare this one with * @return true if both objects represent the same (logical) content */ public boolean equals(Object object) { if (!(object instanceof MimeType)) { return false; } if (this == object) return true; // Don't check the ID - id is only set through OJB so this would not recognize equality correctly /* if (mimeTypeId != ((MimeType)object).getMimetypeId()) return false; */ String oName = ((MimeType)object).getName(); if (oName != null && name != null) { return oName.equals(name); } else if (oName == null && name == null) { return true; } else { return false; } }
temp.add(mt.getName());
JSMimeType jsMimeType = (JSMimeType) refs.mimeMap.get(mimeType.getName()); if (jsMimeType != null) jsMediaType.getMimeTypes().add(jsMimeType);
JSMimeType _mt = (JSMimeType) refs.mimeMap.get(_m.getName()); if (_mt != null) jsC.getMimeTypes().add(_mt);